5

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?

1 Answer 1

4

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'):

keycode  66 = Caps_Lock NoSymbol Caps_Lock

You may play around a bit with xev. Read more at ArchWiki: Xmodmap#Introduction.

How can I detach keys(keycodes) to disable their function as modifiers?

You need to change mapping of CapsLock.

  • To disable CapsLock, you need to unmap it:

    xmodmap -e 'keycode  66 = NoSymbol NoSymbol NoSymbol'
    
  • To enable CapsLock, you need to map it again to default values:

    xmodmap -e 'keycode  66 = Caps_Lock NoSymbol Caps_Lock'
    

What is actually the clear command doing?

It clears mapping of a modifier, not mapping of keycodes. More at ArchWiki: Xmodmap#Modifier_keys

1
  • 1
    My desire behaviour is to only use CapsLock when the ShiftKey is pressed. With your suggestion now works! I was using VoidSymbol instad NoSymbol: xmodmap -e 'clear Lock' -e 'keycode 0x42 = VoidSymbol Caps_Lock' With NoSymbol works as desired, VoidSymbol has no effect. Whats the difference between the two? Seem I can't find documentation about it
    – mxlian
    Sep 25, 2015 at 8:30

You must log in to answer this question.

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