Answering my own question...
Setting up CapsLock as act as a left mouse button turned out to be much simpler than expected. [Note: The physical mouse left mouse button continues to behave as normal.]
1) Map CapsLock to the left mouse button (66 is the CapsLock key code):
$ xmodmap -e "keycode 66 = Pointer_Button1"
2) Map NumLock to CapsLock (77 is the NumLock key code):
$ xmodmap -e "keycode 77 = Caps_Lock"
Note: This means NumLock will act as the CapsLock replacement key, the functionality of NumLock will be lost (I never use it anyway but use a different key if you use NumLock, e.g. Pause, ScollLock, etc.).
3) Enable mousekeys:
$ xkbset mousekeys
Note: xkbset is not installed by default on some distros and this is not the same as enabling Mouse Keys in the Accessibility section of your system settings.
That's it - all done.
However users will probably want to have these tasks done automatically on start-up. Here's what I did:
Create the regular file
/home/user/.Xmodmap and insert the following lines.
! 77 is the NumLock key code, 66 is the CapsLock key code.
! Map CapsLock to the left mouse button and map NumLock to
! CapsLock, i.e. NumLock acts as the CapsLock key used to.
keycode 77 = Caps_Lock
keycode 66 = Pointer_Button1
Note: Comments in
.Xmodmap files start with an
Running xmodmap to load the
~/.Xmodmap file on start-up proved must harder than was expected - the problem being that it must be done very late in the start up sequence or XKB will not have been initiated and XKB will overwrite the xmodmap changes when it loads.
Placing the lines...
~/.xsessionrc all failed.
Creating the file
/etc/X11/Xsession.d/80_xmodmap_user_added to run the commands above, as suggested in How persistently remap keys in Ubuntu 16.04? did not work for me.
Reluctantly I used the graphical start up tool, on Linux Mint this is as follows (your distro may vary):
Mint Menu --> Preferences --> Startup Applications
I created 2 entries, one to call each of the following commands:
For the record I need no auto-start delay in my Startup Applications entries, but try adding a delay if this does not work for you. XKB needs to have been initiated before the commands are run or your changes will be over-ridden by it.
This all works perfectly for me; on start-up CapsLock functions as a left-button mouse key (both single and double clicking work).