Since I rarely use caps-lock, I'd like to map the key to a middle mouse click instead. I would also like to map Alt+Caps Lock to the original function of the caps lock key, should I ever need it.
I can map any keyboard shortcut to xdotool click 2
, but the Gnome Keyboard Shortcuts dialog won't let me assign a command to the caps-lock key, even with modifiers.
I know this is a bit of a strange undertaking; How would I go about doing it?
If you first remove the lock modifier from the Caps Lock key you should then be able to assign the key in Keyboard Shortcuts, use the command below to do that:
Another easy solution if you prefer to use a GUI is to install easystroke:
You can easily map keyboard keys and shortcuts to mouse buttons as well as mouse gestures.
Old question, new answer, copying myself from here: https://superuser.com/questions/947807/emulate-left-mouse-button-with-capslock-key/1409757#1409757
I was looking for CapsLock = left click, which should be similar. After much experimentation I realized I got better results with
xdotool
instead ofxte
.In my
~/.bashrc
(or whatever startup script is appropriate to your system) I added this line:This removes the 'locking' behavior of Caps Lock and assigns that key (key 66) to nothingness. I was tinkering with putting this in other places like
.xinitrc
, but they never worked. It is fairly safe in.bashrc
even though it does get re-run with every terminal session opened (depending on how your.bashrc
is set up overall).For
xbindkeys
I created the file ~/.xbindkeysrc with these lines:A reboot or running
source ~/.bashrc
should make thexmodmap
part work. To reloadxbindkeys
, try this: