1XMODMAP(1) General Commands Manual XMODMAP(1)
2
3
4
6 xmodmap - utility for modifying keymaps and pointer button mappings in
7 X
8
10 xmodmap [-options ...] [filename]
11
13 The xmodmap program is used to edit and display the keyboard modifier
14 map and keymap table that are used by client applications to convert
15 event keycodes into keysyms. It is usually run from the user's session
16 startup script to configure the keyboard according to personal tastes.
17
19 The following options may be used with xmodmap:
20
21 -display display
22 This option specifies the host and display to use.
23
24 -help This option indicates that a brief description of the command
25 line arguments should be printed on the standard error channel.
26 This will be done whenever an unhandled argument is given to
27 xmodmap.
28
29 -grammar
30 This option indicates that a help message describing the
31 expression grammar used in files and with -e expressions should
32 be printed on the standard error.
33
34 -version
35 This option indicates that xmodmap should print its version
36 information and exit.
37
38 -verbose
39 This option indicates that xmodmap should print logging infor‐
40 mation as it parses its input.
41
42 -quiet This option turns off the verbose logging. This is the
43 default.
44
45 -n This option indicates that xmodmap should not change the map‐
46 pings, but should display what it would do, like make(1) does
47 when given this option.
48
49 -e expression
50 This option specifies an expression to be executed. Any number
51 of expressions may be specified from the command line.
52
53 -pm This option indicates that the current modifier map should be
54 printed on the standard output. This is the default mode of
55 operation if no other mode options are specified.
56
57 -pk This option indicates that the current keymap table should be
58 printed on the standard output.
59
60 -pke This option indicates that the current keymap table should be
61 printed on the standard output in the form of expressions that
62 can be fed back to xmodmap.
63
64 -pp This option indicates that the current pointer map should be
65 printed on the standard output.
66
67 - A lone dash means that the standard input should be used as the
68 input file.
69
70 The filename specifies a file containing xmodmap expressions to be exe‐
71 cuted. This file is usually kept in the user's home directory with a
72 name like .xmodmaprc.
73
75 The xmodmap program reads a list of expressions and parses them all
76 before attempting to execute any of them. This makes it possible to
77 refer to keysyms that are being redefined in a natural way without hav‐
78 ing to worry as much about name conflicts.
79
80 The list of keysym names may be found in the header file
81 <X11/keysymdef.h> (without the XK_ prefix), supplemented by the keysym
82 database /usr/share/X11/XKeysymDB. Keysyms matching Unicode charac‐
83 ters may be specified as "U0020" to "U007E" and "U00A0" to "U10FFFF"
84 for all possible Unicode characters.
85
86 keycode NUMBER = KEYSYMNAME ...
87 The list of keysyms is assigned to the indicated keycode (which
88 may be specified in decimal, hex or octal and can be determined
89 by running the xev program). Up to eight keysyms may be
90 attached to a key, however the last four are not used in any
91 major X server implementation. The first keysym is used when
92 no modifier key is pressed in conjunction with this key, the
93 second with Shift, the third when the Mode_switch key is used
94 with this key and the fourth when both the Mode_switch and
95 Shift keys are used.
96
97 keycode any = KEYSYMNAME ...
98 If no existing key has the specified list of keysyms assigned
99 to it, a spare key on the keyboard is selected and the keysyms
100 are assigned to it. The list of keysyms may be specified in
101 decimal, hex or octal.
102
103 keysym KEYSYMNAME = KEYSYMNAME ...
104 The KEYSYMNAME on the left hand side is translated into match‐
105 ing keycodes used to perform the corresponding set of keycode
106 expressions. Note that if the same keysym is bound to multiple
107 keys, the expression is executed for each matching keycode.
108
109 clear MODIFIERNAME
110 This removes all entries in the modifier map for the given mod‐
111 ifier, where valid name are: Shift, Lock, Control, Mod1, Mod2,
112 Mod3, Mod4, and Mod5 (case does not matter in modifier names,
113 although it does matter for all other names). For example,
114 ``clear Lock'' will remove all any keys that were bound to the
115 shift lock modifier.
116
117 add MODIFIERNAME = KEYSYMNAME ...
118 This adds all keys containing the given keysyms to the indi‐
119 cated modifier map. The keysym names are evaluated after all
120 input expressions are read to make it easy to write expressions
121 to swap keys (see the EXAMPLES section).
122
123 remove MODIFIERNAME = KEYSYMNAME ...
124 This removes all keys containing the given keysyms from the
125 indicated modifier map. Unlike add, the keysym names are eval‐
126 uated as the line is read in. This allows you to remove keys
127 from a modifier without having to worry about whether or not
128 they have been reassigned.
129
130 pointer = default
131 This sets the pointer map back to its default settings (button
132 1 generates a code of 1, button 2 generates a 2, etc.).
133
134 pointer = NUMBER ...
135 This sets the pointer map to contain the indicated button
136 codes. The list always starts with the first physical button.
137 Setting a button code to 0 disables events from that button.
138
139 Lines that begin with an exclamation point (!) are taken as comments.
140
141 If you want to change the binding of a modifier key, you must also
142 remove it from the appropriate modifier map.
143
145 Many pointers are designed such that the first button is pressed using
146 the index finger of the right hand. People who are left-handed fre‐
147 quently find that it is more comfortable to reverse the button codes
148 that get generated so that the primary button is pressed using the
149 index finger of the left hand. This could be done on a 3 button
150 pointer as follows:
151 % xmodmap -e "pointer = 3 2 1"
152
153 Many applications support the notion of Meta keys (similar to Control
154 keys except that Meta is held down instead of Control). However, some
155 servers do not have a Meta keysym in the default keymap table, so one
156 needs to be added by hand. The following command will attach Meta to
157 the Multi-language key (sometimes labeled Compose Character). It also
158 takes advantage of the fact that applications that need a Meta key sim‐
159 ply need to get the keycode and don't require the keysym to be in the
160 first column of the keymap table. This means that applications that
161 are looking for a Multi_key (including the default modifier map) won't
162 notice any change.
163 % xmodmap -e "keysym Multi_key = Multi_key Meta_L"
164
165 Similarly, some keyboards have an Alt key but no Meta key. In that
166 case the following may be useful:
167 % xmodmap -e "keysym Alt_L = Meta_L Alt_L"
168
169 One of the more simple, yet convenient, uses of xmodmap is to set the
170 keyboard's "rubout" key to generate an alternate keysym. This fre‐
171 quently involves exchanging Backspace with Delete to be more comfort‐
172 able to the user. If the ttyModes resource in xterm is set as well,
173 all terminal emulator windows will use the same key for erasing charac‐
174 ters:
175 % xmodmap -e "keysym BackSpace = Delete"
176 % echo "XTerm*ttyModes: erase ^?" | xrdb -merge
177
178 Some keyboards do not automatically generate less than and greater than
179 characters when the comma and period keys are shifted. This can be
180 remedied with xmodmap by resetting the bindings for the comma and
181 period with the following scripts:
182 !
183 ! make shift-, be < and shift-. be >
184 !
185 keysym comma = comma less
186 keysym period = period greater
187
188 One of the more irritating differences between keyboards is the loca‐
189 tion of the Control and CapsLock keys. A common use of xmodmap is to
190 swap these two keys as follows:
191 !
192 ! Swap Caps_Lock and Control_L
193 !
194 remove Lock = Caps_Lock
195 remove Control = Control_L
196 keysym Control_L = Caps_Lock
197 keysym Caps_Lock = Control_L
198 add Lock = Caps_Lock
199 add Control = Control_L
200
201 This example can be run again to swap the keys back to their previous
202 assignments.
203
204 The keycode command is useful for assigning the same keysym to multiple
205 keycodes. Although unportable, it also makes it possible to write
206 scripts that can reset the keyboard to a known state. The following
207 script sets the backspace key to generate Delete (as shown above),
208 flushes all existing caps lock bindings, makes the CapsLock key be a
209 control key, make F5 generate Escape, and makes Break/Reset be a shift
210 lock.
211 !
212 ! On the HP, the following keycodes have key caps as listed:
213 !
214 ! 101 Backspace
215 ! 55 Caps
216 ! 14 Ctrl
217 ! 15 Break/Reset
218 ! 86 Stop
219 ! 89 F5
220 !
221 keycode 101 = Delete
222 keycode 55 = Control_R
223 clear Lock
224 add Control = Control_R
225 keycode 89 = Escape
226 keycode 15 = Caps_Lock
227 add Lock = Caps_Lock
228
230 DISPLAY to get default host and display number.
231
233 X(7), xev(1), setxkbmap(1), XStringToKeysym(3), Xlib documentation on
234 key and pointer events
235
237 Every time a keycode expression is evaluated, the server generates a
238 MappingNotify event on every client. This can cause some thrashing.
239 All of the changes should be batched together and done at once.
240 Clients that receive keyboard input and ignore MappingNotify events
241 will not notice any changes made to keyboard mappings.
242
243 Xmodmap should generate "add" and "remove" expressions automatically
244 whenever a keycode that is already bound to a modifier is changed.
245
246 There should be a way to have the remove expression accept keycodes as
247 well as keysyms for those times when you really mess up your mappings.
248
250 Jim Fulton, MIT X Consortium, rewritten from an earlier version by
251 David Rosenthal of Sun Microsystems.
252
253
254
255
256X Version 11 xmodmap 1.0.9 XMODMAP(1)