Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 2 down vote accepted

Apparently, the above xmodmap code is not sufficient to swap the Control_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.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.