4

I've swapped Left Ctrl and Caps Lock by creating ~/.Xmodmap

keycode 66 = Control_L
keycode 37 = Caps_Lock
clear Lock
clear Control
add Lock    = Caps_Lock
add Control = Control_L Control_R

then running $ xmodmap ~/.Xmodmap. Pressing the Left Ctrl key works as expected, toggling Caps Lock. Pressing the Caps Lock key works in general for simple shortcuts, such as Ctrl+N.

However, when multiple modifier keys are required (e.g. Alt+Ctrl+I), this only works if I press the Alt key first. If I press the Caps Lock key first, there is no effect.

I can reset the keyboard layout with $ setxkbmap -layout us, and the above shortcut will work fine. If I run $ xmodmap ~/.Xmodmap again, I have the same problem.

I also find that even for single-modifier combinations, I have to hold down the Caps Lock key for a split-second longer than I used to with the vanilla Ctrl key for it to register. It's probably of the order of 0.01 seconds, but it's noticeable enough that incorrect signals are being sent one in ten times.

Also, if I swap Ctrl and Caps Lock using $ setxkbmap -layout us -option 'ctrl:swapcaps', I no longer notice the problem with the multiple modifiers. However, I still want to work out the problem with the xmodmap solution, as I'm getting a new keyboard soon, and will need to swap Ctrl with a different key.

=EDIT= I've tried another keyboard (Das Keyboard) and it seems that the second problem of having to hold down Caps Lock for a split second longer than I did with Ctrl is probably a hardware issue with the original keyboard (an Aluminium Apple wired keyboard). However, the first problem with multiple modifiers is still present.

=EDIT= I've tested different keystrokes in xev. Holding Alt then pressing the Caps Lock key results in keycode 66 (keysym 0x0, NoSymbol), as opposed to keycode 66 (keysym 0xffe3, Control_L) when Alt is not held.

1 Answer 1

3

Apparently, the above xmodmap code is not sufficient to swap the Ctrl+L and Caps Lock keys.

keycode 66 = Control_L

should be

keycode 66 = Control_L Control_L

to allow correct functionality when Ctrl is pressed after another modifier. I can't find any good references to this solution but apparently the second entry relates to Shift+Key. I'm not sure why here it also seems to apply to Alt+Key.

(Also, FWIW, other sources state there are up to eight columns, rather than the six referred to in the link.)

You must log in to answer this question.

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