xmodmap(X) X Version 11 (Release 4) xmodmap(X) Name xmodmap - utility for modifying keymaps in X Syntax xmodmap [-options ...] [filename] Description xmodmap 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. Options The following options may be used with xmodmap: -display displayname specifies the host and display to use -e expression specifies an expression to be executed. Any number of expres- sions may be specified from the command line. For details on expression grammar, see the next section. -help prints a brief description of the command line arguments to stan- dard error whenever an unhandled argument is given to xmodmap -grammar prints a help message describing the expression grammar used in files and with -e expressions to standard error -verbose prints logging information as xmodmap parses its input -quiet turns off the verbose logging. This is the default. -n xmodmap does not change the mappings, but displays which mappings would change -pm prints the current modifier map to standard output -pk prints the current keymap table to standard output -pp prints the current pointer (mouse cursor button) map to standard output - reads standard input filename specifies a file containing xmodmap expressions to be executed. This file is usually kept in the user's home directory with a name such as .xmodmaprc. Expression grammar xmodmap reads and parses a list of expressions executing them. Conse- quently, you can refer to keysyms that are being redefined without spe- cial concern for name conflicts. _________________________________________________________________________ NOTE Expressions require spaces around the ``='' character. _________________________________________________________________________ keycode number = keysymlist The list of keysyms, keysymlist, is assigned to keycode number in the server's keymap table. number may be specified in decimal, hex or octal and can be determined by running the xev program. For details on the format of the keymap table, see Xsco(X). Usu- ally only one keysym is assigned to a given keycode. keysym keysymname = keysymlist The keymap table line containing keysymname is replaced with keysymlist. Note that this procedure may fail if keysymname is bound to multiple keys. For details on the format of the keymap table, see Xsco(X). clear modifiername removes all entries in the modifier map for the given modifier. The valid names are ``Shift'', ``Lock'', ``Control'', ``Mod1'', ``Mod2'', ``Mod3'', ``Mod4'' and ``Mod5'' (case does not matter in modifier names). For example, clear Lock removes all any keys bound to the shift lock modifier. add modifiername = keysymname adds the given keysyms to the indicated modifier map. The keysym names are evaluated after all input expressions are read to facilitate writing expressions to swap keys (see the ``Examples'' section). remove modifiername = keysymname removes the given keysyms from the indicated modifier map. Unlike add, the keysym names are evaluated as the line is read in. This allows you to remove keys from a modifier regardless of whether they were reassigned. If you want to change the binding of a modifier key, you must also remove it from the appropriate modifier map. pointer = default sets the pointer map back to its default settings (button 1 gen- erates a code of 1, button 2 generates a 2, and so forth) pointer = number sets to pointer map to contain the indicated button codes. The list always starts with the first physical button. Lines that begin with an exclamation point (!) are comments. Examples Most pointers are designed for right-handed users with the left button corresponding to mouse button 1. Consequently, left-handed users often need to reverse the button codes that are generated so that the the right button corresponds to mouse button 1. This can be done on a 3 button pointer as follows: % xmodmap -e "pointer = 3 2 1" Many editor applications support the notion of Meta keys (similar to con- trol keys except that Meta is held down instead of Ctrl). With servers that lack a Meta keysym in the default keymap table, a Meta keysym must be added. The following command attaches Meta to the Multi-language key (sometimes labeled Compose Character): % keysym Multikey = Multikey MetaL This command 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. Applications looking for a Multi_key (including the default modifier map) consequently do not notice any change. One of the more simple, yet convenient, uses of xmodmap is setting the keyboard's rubout key to generate an alternate keysym. This frequently involves exchanging Bksp with Del. If the ttyModes resource in xterm is also set, all terminal emulator windows use the same key for erasing characters: % xmodmap -e "keysym BackSpace = Delete" % echo "XTerm*ttyModes: erase ^?" | xrdb -merge Some keyboards do not automatically generate ``less than'' and ``greater than'' characters when the comma and period keys are shifted. xmodmap can compensate for this lack if you reset the bindings for the comma and pe- riod with the following scripts: ! ! make shift-, be < and shift-. be > ! keysym comma = comma less keysym period = period greater Some users may want to reverse the location of the Ctrl and Shift Lock keys. They can use xmodmap to reverse these two keys as follows: ! ! 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 allows you to write scripts that can reset the keyboard to a known state. The following script sets the Bksp key to generate Delete (as shown above), flushes all existing CapsLock bindings, makes the CapsLock key into a control key, makes F5 generate Escape, and makes Break/Reset be a shift lock. ! ! 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 Environment DISPLAY specifies the default host and display number Limitations When a keycode expression is evaluated, the server generates a MappingNo- tify event on every client. This can cause some thrashing. All changes should be batched together and completed as a group. Clients that receive keyboard input and ignore MappingNotify events do not notice changes made to keyboard mappings. See also X(X), Xsco(X), xev(X), xsconfig(X) Copyright Copyright 1988, Massachusetts Institute of Technology. Copyright 1987 Sun Microsystems, Inc. See X(X) for a full statement of rights and per- missions.