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 of xte
.
In my ~/.bashrc
(or whatever startup script is appropriate to your system) I added this line:
/usr/bin/xmodmap -e "keycode 66 ="
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:
"xdotool mousedown 1"
c:66
"xdotool mouseup 1"
release + c:66
A reboot or running source ~/.bashrc
should make the xmodmap
part work. To reload xbindkeys
, try this:
killall xbindkeys
xbindkeys -f ~/.xbindkeysrc