I know this xmodmap script can swap ctrl and capslock:
remove Lock = Caps_Lock
remove Control = Control_L
keysym Caps_Lock = Control_L
keysym Control_L = Caps_Lock
add Lock = Caps_Lock
add Control = Control_L
I don't quite understand it. So I tried this:
remove Lock = Caps_Lock
remove Control = Control_L
add Lock = Control_L
add Control = Caps_Lock
And this script doesn't work.
Could some explain this(why the 1st script works and the other one doesn't) in simple words?
Best Answer
From Remap Caps Lock:
Those
keysym
lines are important since they're the ones that are mapping the keycodes to the opposing keys, i.e. keycode for Capslock goes to Control L and vice versa.excerpt from the xmodmap man page*
Seeing the effect
You can use the tool
xev
to see that the keys have been literally remapped. So Capslock now sends the scancode for Control L.Example
Pressing Capslock sends Control L.
Pressing Control L sends Capslock.
References