Xmodmap
xmodmap versus XKB
xmodmap is outdated
X keyboard extension (XKB) should be used instead.
XKB defines the way keyboards codes are handled in X, and provides access to internal translation tables. It is the basic mechanism that allows using multiple keyboard layouts in X.
However, for simple tasks, xmodmap is still valid / usefull.
https://wiki.archlinux.org/title/X_keyboard_extension
xkeycaps
is a graphical front-end to xmodmap.
sudo apt install xkeycaps
change an action to another key
xmodmap -e "keycode 78 = Caps_Lock" ==> pressing scrollock executes the capslock action
xmodmap needs :
- the -e param
- the keycode of the NEW key being pressed
- the “action” of the OLD or existing key for that function.
list config assigned to the keys
xmodmap -pk
use grep to filter :
xmodmap -pk | grep 'Caps' ( grep ‘Scroll’ )
==>
66 0xffe5 (Caps_Lock) 0x0000 (NoSymbol) 0xffe5 (Caps_Lock)
78 0xff14 (Scroll_Lock) 0x0000 (NoSymbol) 0xff14 (Scroll_Lock)
the current modifier table verbosely (full sample):
xmodmap -pm
modifier keys
xmodmap can also be used to override modifier keys, e.g. to swap Control and Super (the Windows key).
modifier key sequences
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), Meta_L (0xcd)
mod2 Num_Lock (0x94)
mod3
mod4 Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), ISO_Level3_Shift (0x6c), Mode_switch (0x85), Mode_switch (0xcb)
3. TODO
deeper study of xmodmap command & XKB
both can be used to modify many other key behaviours
see :
https://wiki.archlinux.org/title/Xmodmap
https://superuser.com/questions/283548/remapping-capslock-key
http://xed.ch/h/capslock.html
https://wiki.archlinux.org/title/X_keyboard_extension
https://wiki.archlinux.org/title/xmodmap