Graphics Administration Guide (April 2009)

Table 4-1 Expression Types
Use this expression. . .To do this. . .
keycode <keycode> = <keysym>Assign a key symbol to a keycode
keysym <keysym> = <keysym>Replace a key symbol expression with another
clear<modifier>Clear all keys associated with a modifier key
add <modifier>= <keysym>Add a key symbol to a modifier
remove <modifier> = <keysym>Remove a key symbol from a modifier
keycode
Refers to the numerical value that uniquely identifies each key on a keyboard. Values may be in
decimal, octal, or hexadecimal.
keysym
Refers to the character symbol name associated with a keycode; for example, KP_Add.
<modifier >
Specifies one of the eight modifier names: Shift, Control, Lock, Mod1, Mod2, Mod3, Mod4, and
Mod5.
On Hewlett-Packard keyboards, the lock modifier is set to the Caps Lock key. However, any of
the modifiers can be associated with any valid key symbol. Additionally, you can associate more
than one key symbol with a modifier (such as Lock = Shift_R and Lock = Shift_L), and you can
associate more than one modifier with a key symbol (for example, Control = Caps_Lock and
Lock = Caps_Lock).
For example, on a PC-style keyboard, you can press Dto print a lower case "d", Shift Dto print
a capital "D", Alt Dto print something else, and Shift Alt Dto print still something else.
The xmodmap client gives you the power to change the meaning of any key at any time or to
install a whole new key map for your keyboard.
examples
Suppose you frequently press the Caps Lockkey at the most inopportune moments. You could
remove the Caps Lockkey from the lock modifier, swap it for the f1 key, then map the f1key to
the lock modifier. Do this by creating a little swapper file that contains the following lines:
!This file swaps the [Caps] key with the [F1] key.
remove Lock = Caps_Lock
keysym Caps_Lock = F1
keysym F1 = Caps_Lock
add Lock = Caps_Lock
Note the use of the ! in the file to start a comment line. To put your "swapper" file into effect,
enter the following on the command line:
xmodmap swapper
If you use such a swapper file, you should probably have an unswapper file. The following file
enables you to swap back to the original keyboard mapping without having to exit X11:
!This file unswaps the [F1] key with the [Caps Lock] key.
remove Lock = Caps_Lock
keycode 88 = F1
keycode 55 = Caps_Lock
add Lock = Caps_Lock
Note the use of the hexadecimal values to reinitialize the keycodes to the proper key symbols.
You put your “unswapper file into effect by entering the following command line:
xmodmap unswapper
customizing the mouse and keyboard 41