This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!
xmodmap is a program used to edit and display the keyboard modifier map and key map/table that
are used by client applications to convert event keycodes into keysyms.
A modifier key is a special key (or combination) on a computer keyboard that temporarily modifies the normal action of another key when pressed together. By themselves, modifier keys usually do nothing; that is, pressing any of the Shift, Alt, or Ctrl keys alone does not (generally) trigger any action from the computer.
There are two types of keyboard values in Xorg: keycodes and keysyms.
keycode: The keycode is the numeric representation received by the kernel when a key or a mouse button is pressed.
keysym: The keysym is the value assigned to the keycode. For example, pressing A generates
38, which is mapped to the keysym
0×61, which matches a in the ASCII table. The
keysyms are managed by Xorg in a table of keycodes defining the keycode to keysym relations,
which is called the key map table. This can be shown by running
Table of contents¶
xmodmap config file, a custom key map/table, and load it when starting your X session:
$ vi ~/.config/Xmodmap > ! this is a comment > ... $ vi ~/.xinitrc > ... > [[ -f ~/.config/Xmodmap ]] && xmodmap ~/.config/Xmodmap & > ...
Print the current modifiers:
List keycodes and associated symbols (key map table formatted into expressions):
Each keycode is followed by the keysym it is mapped to. For example
keycode 57 = n N
indicates that the keycode
57 is mapped to the lowercase
n, while the uppercase
mapped to keycode
57 + Shift.
Each keysym column in the table corresponds to a particular combination of modifier keys:
Not all keysyms have to be set, but to assign only a latter keysym, use the
To identify X11 input keycodes, the
xev utility can be used. Just run
$ xev in your
terminal and enter the key in order to get its details. A lot of information will be output,
with the following command you can start
xev and show only the relevant parts:
There are predefined descriptive keysyms for multimedia keys, e.g.
XF86Mail. These keysyms can be found in
/usr/include/X11/XF86keysym.h. Many multimedia
programs are designed to work with these keysyms out of the box, without the need to configure
any third party application. Also, note that available keysyms depend on the
$ man xkeyboard-config for more details).
Test temporary changes, e.g. replace
a keysym will be translated to
Test temporary changes, e.g. assign different keysyms to keycode
Test remanent changes, i.e. changes made in the
xmodmap config file:
$ vi ~/.config/Xmodmap > ... > keysym a = e > keycode 24 = e E e E > ... $ xmodmap ~/.config/Xmodmap
Reverse pointer buttons:
Turn caps lock into control:
xmodmapman page's example section for more examples.
If this cheat sheet has been useful to you, then please consider leaving a star here.