12

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?

3 Answers 3

5

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:

echo  'remove lock = Caps_Lock' | xmodmap -
1
  • very good! any chance to get caps lock back onto alt+capslock? Dec 18, 2010 at 16:36
3

Another easy solution if you prefer to use a GUI is to install easystroke:

sudo apt-get install easystroke

You can easily map keyboard keys and shortcuts to mouse buttons as well as mouse gestures.

0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .