Trying to understand XKB and how to customize keyboard mappings, specially for modifiers.
A little experiment on disabling modifiers, leads to an unexpected result:
(1) Modifier maps before
$ xmodmap -pm
xmodmap: up to 4 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25), Control_R (0x69)
mod1 Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
(2) Clear lock modifier
$ xmodmap -e 'clear Lock'
(3) Cleared ok
$ xmodmap -pm
xmodmap: up to 4 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock
control Control_L (0x25), Control_R (0x69)
mod1 Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
I expected to disable CapsLock from setting the lock state, but it does't.
It works as usual, and using xev
to see the key press events, I see that the lock flag still changes (state 0x0
when CapsLock is off, state 0x2
when on).
What is actually the clear
command doing?
How can I detach keys(keycodes) to disable their function as modifiers?
Best Answer
Actually, CapsLock functionality is bound to keysym value of pressed key. To see mapping of keycodes to keysyms execute
xmodmap -pke
. The mapping of CapsLock (keycode 66) should be (| grep 'keycode 66'
):You may play around a bit with
xev
. Read more at ArchWiki: Xmodmap#Introduction.You need to change mapping of CapsLock.
To disable CapsLock, you need to unmap it:
To enable CapsLock, you need to map it again to default values:
It clears mapping of a modifier, not mapping of keycodes. More at ArchWiki: Xmodmap#Modifier_keys