1 .\" Copyright (c) 1987, 2010, Oracle and/or its affiliates. All rights reserved.
3 .\" Permission is hereby granted, free of charge, to any person obtaining a
4 .\" copy of this software and associated documentation files (the "Software"),
5 .\" to deal in the Software without restriction, including without limitation
6 .\" the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 .\" and/or sell copies of the Software, and to permit persons to whom the
8 .\" Software is furnished to do so, subject to the following conditions:
10 .\" The above copyright notice and this permission notice (including the next
11 .\" paragraph) shall be included in all copies or substantial portions of the
14 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 .\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 .\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 .\" THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 .\" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 .\" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 .\" DEALINGS IN THE SOFTWARE.
22 .\" Copyright 1988, 1989, 1990, 1998 The Open Group
24 .\" Permission to use, copy, modify, distribute, and sell this software and its
25 .\" documentation for any purpose is hereby granted without fee, provided that
26 .\" the above copyright notice appear in all copies and that both that
27 .\" copyright notice and this permission notice appear in supporting
30 .\" The above copyright notice and this permission notice shall be included
31 .\" in all copies or substantial portions of the Software.
33 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
34 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
35 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
36 .\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
37 .\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
38 .\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
39 .\" OTHER DEALINGS IN THE SOFTWARE.
41 .\" Except as contained in this notice, the name of The Open Group shall
42 .\" not be used in advertising or otherwise to promote the sale, use or
43 .\" other dealings in this Software without prior written authorization
44 .\" from The Open Group.
46 .de EX \"Begin example
59 .TH XMODMAP 1 __xorgversion__
61 xmodmap - utility for modifying keymaps and pointer button mappings in X
64 [-options ...] [filename]
67 The \fIxmodmap\fP program is used to edit and display the
68 keyboard \fImodifier map\fP and \fIkeymap table\fP that are used by client
69 applications to convert event keycodes into keysyms. It is usually run from
70 the user's session startup script to configure the keyboard according to
74 The following options may be used with \fIxmodmap\fP:
76 .B \-display \fIdisplay\fP
77 This option specifies the host and display to use.
80 This option indicates that a brief description of the command line arguments
81 should be printed on the standard error channel. This will be done whenever an
82 unhandled argument is given to
86 This option indicates that a help message describing the expression grammar
87 used in files and with \-e expressions should be printed on the standard error.
90 This option indicates that
92 should print logging information as it parses its input.
95 This option turns off the verbose logging. This is the default.
98 This option indicates that
100 should not change the mappings, but should display what it would do, like
101 \fImake(__appmansuffix__)\fP does when given this option.
103 .B \-e \fIexpression\fB
104 This option specifies an expression to be executed. Any number of expressions
105 may be specified from the command line.
108 This option indicates that the current modifier map should be printed on the
109 standard output. This is the default mode of operation if no other mode
110 options are specified.
113 This option indicates that the current keymap table should be printed on the
117 This option indicates that the current keymap table should be printed on the
118 standard output in the form of expressions that can be fed back to
122 This option indicates that the current pointer map should be printed on the
126 A lone dash means that the standard input should be used as the input file.
128 The \fIfilename\fP specifies a file containing \fIxmodmap\fP expressions
129 to be executed. This file is usually kept in the user's home directory with
130 a name like \fI.xmodmaprc\fP.
131 .SH EXPRESSION GRAMMAR
135 program reads a list of expressions and parses them all before attempting
136 to execute any of them. This makes it possible to refer to keysyms that are
137 being redefined in a natural way without having to worry as much about name
140 The list of keysym names may be found in the header file
141 \fI<X11/keysymdef.h>\fP (without the \fIXK_\fP prefix),
142 supplemented by the keysym database \fI __X11datadir__/XKeysymDB\fP.
143 Keysyms matching Unicode characters may be specified as "U0020" to "U007E"
144 and "U00A0" to "U10FFFF" for all possible Unicode characters.
146 .B keycode \fINUMBER\fP = \fIKEYSYMNAME ...\fP
147 The list of keysyms is assigned to the indicated keycode
148 (which may be specified in decimal, hex or octal and can be determined by
151 program). Up to eight keysyms may be attached to a key, however the last four
152 are not used in any major X server implementation. The first keysym is used
153 when no modifier key is pressed in conjunction with this key, the second with
154 Shift, the third when the Mode_switch key is used with this key and the fourth
155 when both the Mode_switch and Shift keys are used.
157 .B keycode any = \fIKEYSYMNAME ...\fP
158 If no existing key has the specified list of keysyms assigned to it,
159 a spare key on the keyboard is selected and the keysyms are assigned to it.
160 The list of keysyms may be specified in decimal, hex or octal.
162 .B keysym \fIKEYSYMNAME\fP = \fIKEYSYMNAME ...\fP
163 The \fIKEYSYMNAME\fP on the left hand side is translated into matching keycodes
164 used to perform the corresponding set of \fBkeycode\fP expressions. Note that
165 if the same keysym is bound to multiple keys, the expression is executed
166 for each matching keycode.
168 .B clear \fIMODIFIERNAME\fP
169 This removes all entries in the modifier map for the given modifier, where
179 does not matter in modifier names, although it does matter for all other
180 names). For example, ``clear Lock'' will remove
181 all any keys that were bound to the shift lock modifier.
183 .B add \fIMODIFIERNAME\fP = \fIKEYSYMNAME ...\fP
184 This adds all keys containing the given keysyms to the indicated modifier map.
186 are evaluated after all input expressions are read to make it easy to write
187 expressions to swap keys (see the EXAMPLES section).
189 .B remove \fIMODIFIERNAME\fP = \fIKEYSYMNAME ...\fP
190 This removes all keys containing the given keysyms from the indicated
193 the keysym names are evaluated as the line is read in. This allows you to
194 remove keys from a modifier without having to worry about whether or not they
195 have been reassigned.
197 .B "pointer = default"
198 This sets the pointer map back to its default settings (button 1 generates a
199 code of 1, button 2 generates a 2, etc.).
201 .B pointer = \fINUMBER ...\fP
202 This sets the pointer map to contain the indicated button codes. The list
203 always starts with the first physical button. Setting a button code to 0
204 disables events from that button.
206 Lines that begin with an exclamation point (!) are taken as comments.
208 If you want to change the binding of a modifier key, you must also remove it
209 from the appropriate modifier map.
212 Many pointers are designed such that the first button is pressed using the
213 index finger of the right hand. People who are left-handed frequently find
214 that it is more comfortable to reverse the button codes that get generated
215 so that the primary button is pressed using the index finger of the left hand.
216 This could be done on a 3 button pointer as follows:
218 % xmodmap -e "pointer = 3 2 1"
221 Many applications support the notion of Meta keys (similar to Control
222 keys except that Meta is held down instead of Control). However,
223 some servers do not have a Meta keysym in the default keymap table, so one
224 needs to be added by hand.
225 The following command will attach Meta to the Multi-language key (sometimes
226 labeled Compose Character). It also takes advantage of the fact that
227 applications that need a Meta key simply need to get the keycode and don't
228 require the keysym to be in the first column of the keymap table. This
229 means that applications that are looking for a Multi_key (including the
230 default modifier map) won't notice any change.
232 % xmodmap -e "keysym Multi_key = Multi_key Meta_L"
235 Similarly, some keyboards have an Alt key but no Meta key.
236 In that case the following may be useful:
238 % xmodmap -e "keysym Alt_L = Meta_L Alt_L"
241 One of the more simple, yet convenient, uses of \fIxmodmap\fP is to set the
242 keyboard's "rubout" key to generate an alternate keysym. This frequently
243 involves exchanging Backspace with Delete to be more comfortable to the user.
244 If the \fIttyModes\fP resource in \fIxterm\fP is set as well, all terminal
245 emulator windows will use the same key for erasing characters:
247 % xmodmap -e "keysym BackSpace = Delete"
248 % echo "XTerm*ttyModes: erase ^?" | xrdb -merge
251 Some keyboards do not automatically generate less than and greater than
252 characters when the comma and period keys are shifted. This can be remedied
253 with \fIxmodmap\fP by resetting the bindings for the comma and period with
254 the following scripts:
257 ! make shift-, be < and shift-. be >
259 keysym comma = comma less
260 keysym period = period greater
263 One of the more irritating differences between keyboards is the location of the
264 Control and Shift Lock keys. A common use of \fIxmodmap\fP is to swap these
268 ! Swap Caps_Lock and Control_L
270 remove Lock = Caps_Lock
271 remove Control = Control_L
272 keysym Control_L = Caps_Lock
273 keysym Caps_Lock = Control_L
275 add Control = Control_L
278 This example can be run again to swap the keys back to their previous
281 The \fIkeycode\fP command is useful for assigning the same keysym to
282 multiple keycodes. Although unportable, it also makes it possible to write
283 scripts that can reset the keyboard to a known state. The following script
284 sets the backspace key to generate Delete (as shown above), flushes all
285 existing caps lock bindings, makes the CapsLock
286 key be a control key, make F5 generate Escape, and makes Break/Reset be a
290 ! On the HP, the following keycodes have key caps as listed:
300 keycode 55 = Control_R
302 add Control = Control_R
304 keycode 15 = Caps_Lock
311 to get default host and display number.
313 X(__miscmansuffix__), xev(__appmansuffix__), setxkbmap(__appmansuffix__),
314 XStringToKeysym(__libmansuffix__),
315 \fIXlib\fP documentation on key and pointer events
318 Every time a \fBkeycode\fP expression is evaluated, the server generates
319 a \fIMappingNotify\fP event on every client. This can cause some thrashing.
320 All of the changes should be batched together and done at once.
321 Clients that receive keyboard input and ignore \fIMappingNotify\fP events
322 will not notice any changes made to keyboard mappings.
325 should generate "add" and "remove" expressions automatically
326 whenever a keycode that is already bound to a modifier is changed.
328 There should be a way to have the
330 expression accept keycodes as well as keysyms for those times when you really
331 mess up your mappings.
333 Jim Fulton, MIT X Consortium, rewritten from an earlier version by
334 David Rosenthal of Sun Microsystems.