xmodmap - utility for modifying keymaps and pointer button mappings in X
xmodmap [-options ...? [filename?
The xmodmap program is used to edit and display the keyboard modifier map and keymap table that are used by client applications to convert event keycodes into keysyms. It is usually run from the user's session startup script to configure the keyboard according to personal tastes.
The following options may be used with xmodmap:
The filename specifies a file containing xmodmap expressions to be executed. This file is usually kept in the user's home directory with a name like .xmodmaprc.
The xmodmap program reads a list of expressions and parses them all before attempting to execute any of them. This makes it possible to refer to keysyms that are being redefined in a natural way without having to worry as much about name conflicts.
Lines that begin with an exclamation point (!) are taken as comments.
If you want to change the binding of a modifier key, you must also remove it from the appropriate modifier map.
Many applications support the notion of Meta keys (similar to Control keys except that Meta is held down instead of Control). However, some servers do not have a Meta keysym in the default keymap table, so one needs to be added by hand. The following command will attach Meta to the Multi-language key (sometimes labeled Compose Character). It also takes advantage of the fact that applications that need a Meta key simply need to get the keycode and don't require the keysym to be in the first column of the keymap table. This means that applications that are looking for a Multi_key (including the default modifier map) won't notice any change.
% xmodmap -e "keysym Multi_key = Multi_key Meta_L"
keysym comma = comma less keysym period = period greater
Swap Caps_Lock and Control_L ! remove Lock = Caps_Lock remove Control = Control_L keysym Control_L = Caps_Lock keysym Caps_Lock = Control_L add Lock = Caps_Lock add Control = Control_L
The keycode command is useful for assigning the same keysym to multiple keycodes. Although unportable, it also makes it possible to write scripts that can reset the keyboard to a known state. The following script sets the backspace key to generate Delete (as shown above), flushes all existing caps lock bindings, makes the !CapsLock? key be a control key, make F5 generate Escape, and makes Break/Reset be a shift lock.
On the HP, the following keycodes have key caps as listed:
101 Backspace
55 Caps
14 Ctrl
15 Break/Reset
86 Stop
89 F5
keycode 101 = Delete keycode 55 = Control_R clear Lock add Control = Control_R keycode 89 = Escape keycode 15 = Caps_Lock add Lock = Caps_Lock
X(7x)?, xev(1), Xlib documentation on key and pointer events
Every time a keycode expression is evaluated, the server generates a !MappingNotify? event on every client. This can cause some thrashing. All of the changes should be batched together and done at once. Clients that receive keyboard input and ignore !MappingNotify? events will not notice any changes made to keyboard mappings.
Xmodmap should generate "add" and "remove" expressions automatically whenever a keycode that is already bound to a modifier is changed.
There should be a way to have the remove expression accept keycodes as well as keysyms for those times when you really mess up your mappings.
Jim Fulton, MIT X Consortium, rewritten from an earlier version by David Rosenthal of Sun Microsystems.
6 pages link to xmodmap(1):