Difference between revisions of "Xmodmap"
m (→Reverse Scrolling)
(remove language suffix from Category:Input devices (English), see Talk:Table of Contents#English Category Names: Capitalization and Conflict with i18n)
|Line 1:||Line 1:|
[[Category:X Server (English)]]
[[Category:X Server (English)]]
Revision as of 17:38, 21 April 2012
|Summary help replacing me|
|A general overview of modifying keymaps and pointer mappings with xmodmap.|
|Extra Keyboard Keys|
|Extra Keyboard Keys in Xorg|
|Extra Keyboard Keys in Console|
Xmodmap is a utility for modifying keymaps and pointer button mappings in Xorg.
The Linux kernel generates a code each time a key is pressed on a keyboard. That code is compared to a
table of keycodes defining a figure that is then displayed.
This process is complicated by Xorg, which starts its own table of keycodes. Each keycode can belong to a
keysym. A keysym is like a function, started by typing a key. Xmodmap allows you to edit these keycode-keysym relations.
Print the current keymap table formatted into expressions:
$ xmodmap -pke
keycode 57 = n N
Each keymap is followed by the
keysyms it is mapped to. The above example indicates that the keycode
57 is mapped to the lowercase n, while the uppercase N is mapped to keycode
Each keysym column in the table corresponds to a particular key combination:
Not all keysyms have to be set, but if you want to assign a latter keysym without assigning earlier ones set them to
You can check which keymap corresponds to a key on your keyboard with xev.
You can create your own map and store it in your home directory (i.e.
~/.Xmodmap). Print the current keymap table into a configuration file:
xmodmap -pke > ~/.Xmodmap
Make the desired changes to
~/.Xmodmap and then test the new configuration with:
To activate your custom table when starting Xorg add the following:
if [ -f $HOME/.Xmodmap ]; then /usr/bin/xmodmap $HOME/.Xmodmap fi
Alternatively, edit the global startup script
You can also make temporary changes for the current session. For example:
xmodmap -e "keycode 46 = l L l L lstroke Lstroke lstroke" xmodmap -e "keysym a = e E"
At first you have to delete/clear the signals that should be edited. In the beginning of your
!clear Shift !clear Lock clear Control !clear Mod1 !clear Mod2 !clear Mod3 clear Mod4 !clear Mod5 keycode 8 = ...
Write the new signals at the end of
keycode 255 = !add Shift = Shift_L Shift_R !add Lock = Caps_Lock add Control = Super_L Super_R !add Mod1 = Alt_L Alt_R !add Mod2 = Mode_switch !add Mod3 = add Mod4 = Control_L Control_R !add Mod5 =
The natural scrolling feature available in OS X Lion can be mimicked with xmodmap. Since the synaptics driver uses the buttons 4/5/6/7 for up/down/left/right scrolling, you simply need to swap the order of how the buttons are declared in
~/.Xmodmap and append the following line to the file:
pointer = 1 2 3 5 4 7 6 8 9 10 11 12
Note how the 4 and 5 have been reversed.
Then update xmodmap:
To return to regular scrolling simply reverse the order of the 4 and 5 or delete the line altogether. For more information check Peter Hutterer's post, Natural scrolling in the synaptics driver, or the Reverse scrolling direction ala Mac OS X Lion? forum thread.