Quantcast
Channel: Can I map Control to the Caps Lock key and keep the toggle functionality in Linux? - Super User
Viewing all articles
Browse latest Browse all 3

Answer by regnarg for Can I map Control to the Caps Lock key and keep the toggle functionality in Linux?

$
0
0

As Ignacio said, it cannot be done with keymaps. But it can be e.g. simply scripted using xbindkeys and xdotool.

First, strip Caps Lock of its special functionality using xmodmap (this has to be done each time X is started):

xmodmap -e 'keycode 66 = F13'

Then, add the following bindings to you .xbindkeysrc:

"xdotool keyup Control_L; xdotool keydown Control_L"    F13"xdotool keydown Control_L; xdotool keyup Control_L"    Control + F13

This creates a fake keypress (without release) of the Ctrl key whenever Caps Lock (now F13) is pressed. The up+down sequence is there for some technical reasons of how the fake events work.

In this version, pressing (left) Ctrl releases the lock. This could be modified (either so that both controls release it, or neither does) but it would be a little more complicated (e.g. one could create another control key (e.g. F14) and fake-press that instead of Control_L).


Viewing all articles
Browse latest Browse all 3