1KEYMAPS(5) File Formats Manual KEYMAPS(5)
2
3
4
6 keymaps - keyboard table descriptions for loadkeys and dumpkeys
7
9 These files are used by loadkeys(1) to modify the translation tables
10 used by the kernel keyboard driver and generated by dumpkeys(1) from
11 those translation tables.
12
13 The format of these files is vaguely similar to the one accepted by
14 xmodmap(1). The file consists of charset or key or string definition
15 lines interspersed with comments.
16
17 Comments are introduced with ! or # characters and continue to the end
18 of the line. Anything following one of these characters on that line is
19 ignored. Note that comments need not begin from column one as with
20 xmodmap(1).
21
22 The syntax of keymap files is line oriented; a complete definition must
23 fit on a single logical line. Logical lines can, however, be split into
24 multiple physical lines by ending each subline with the backslash char‐
25 acter (\).
26
28 A keymap can include other keymaps using the syntax
29
30 include "pathname"
31
33 A character set definition line is of the form:
34
35 charset "iso-8859-x"
36
37 It defines how following keysyms are to be interpreted. For example,
38 in iso-8859-1 the symbol mu (or micro) has code 0265, while in
39 iso-8859-7 the letter mu has code 0354.
40
42 Each complete key definition line is of the form:
43
44 keycode keynumber = keysym keysym keysym...
45
46 keynumber is the internal identification number of the key, roughly
47 equivalent to the scan code of it. keynumber can be given in decimal,
48 octal or hexadecimal notation. Octal is denoted by a leading zero and
49 hexadecimal by the prefix 0x.
50
51 Each of the keysyms represent keyboard actions, of which up to 256 can
52 be bound to a single key. The actions available include outputting
53 character codes or character sequences, switching consoles or keymaps,
54 booting the machine etc. (The complete list can be obtained from dump‐
55 keys(1) by saying dumpkeys -l .)
56
57 Each keysym may be prefixed by a '+' (plus sign), in wich case this
58 keysym is treated as a "letter" and therefore affected by the "Cap‐
59 sLock" the same way as by "Shift" (to be correct, the CapsLock inverts
60 the Shift state). The ASCII letters ('a'-'z' and 'A'-'Z') are made
61 CapsLock'able by default. If Shift+CapsLock should not produce a lower
62 case symbol, put lines like
63
64 keycode 30 = +a A
65
66 in the map file.
67
68 Which of the actions bound to a given key is taken when it is pressed
69 depends on what modifiers are in effect at that moment. The keyboard
70 driver supports 9 modifiers. These modifiers are labeled (completely
71 arbitrarily) Shift, AltGr, Control, Alt, ShiftL, ShiftR, CtrlL, CtrlR
72 and CapsShift. Each of these modifiers has an associated weight of
73 power of two according to the following table:
74
75
76 modifier weight
77
78 Shift 1
79 AltGr 2
80 Control 4
81 Alt 8
82 ShiftL 16
83 ShiftR 32
84 CtrlL 64
85 CtrlR 128
86 CapsShift 256
87
88 The effective action of a key is found out by adding up the weights of
89 all the modifiers in effect. By default, no modifiers are in effect, so
90 action number zero, i.e. the one in the first column in a key defini‐
91 tion line, is taken when the key is pressed or released. When e.g.
92 Shift and Alt modifiers are in effect, action number nine (from the
93 10th column) is the effective one.
94
95 Changing the state of what modifiers are in effect can be achieved by
96 binding appropriate key actions to desired keys. For example, binding
97 the symbol Shift to a key sets the Shift modifier in effect when that
98 key is pressed and cancels the effect of that modifier when the key is
99 released. Binding AltGr_Lock to a key sets AltGr in effect when the key
100 is pressed and cancels the effect when the key is pressed again. (By
101 default Shift, AltGr, Control and Alt are bound to the keys that bear a
102 similar label; AltGr may denote the right Alt key.)
103
104 Note that you should be very careful when binding the modifier keys,
105 otherwise you can end up with an unusable keyboard mapping. If you for
106 example define a key to have Control in its first column and leave the
107 rest of the columns to be VoidSymbols, you're in trouble. This is
108 because pressing the key puts Control modifier in effect and the fol‐
109 lowing actions are looked up from the fifth column (see the table
110 above). So, when you release the key, the action from the fifth column
111 is taken. It has VoidSymbol in it, so nothing happens. This means that
112 the Control modifier is still in effect, although you have released the
113 key. Re-pressing and releasing the key has no effect. To avoid this,
114 you should always define all the columns to have the same modifier sym‐
115 bol. There is a handy short-hand notation for this, see below.
116
117 keysyms can be given in decimal, octal, hexadecimal, unicode or sym‐
118 bolic notation. The numeric notations use the same format as with
119 keynumber. Unicode notation is "U+" followed by four hexadecimal dig‐
120 its. The symbolic notation resembles that used by xmodmap(1). Notable
121 differences are the number symbols. The numeric symbols '0', ..., '9'
122 of xmodmap(1) are replaced with the corresponding words 'zero', 'one',
123 ... 'nine' to avoid confusion with the numeric notation.
124
125 It should be noted that using numeric notation for the keysyms is
126 highly unportable as the key action numbers may vary from one kernel
127 version to another and the use of numeric notations is thus strongly
128 discouraged. They are intended to be used only when you know there is a
129 supported keyboard action in your kernel for which your current version
130 of loadkeys(1) has no symbolic name.
131
132 There is a number of short-hand notations to add readability and reduce
133 typing work and the probability of typing-errors.
134
135 First of all, you can give a map specification line, of the form
136
137 keymaps 0-2,4-5,8,12
138
139 to indicate that the lines of the keymap will not specify all 256 col‐
140 umns, but only the indicated ones. (In the example: only the plain,
141 Shift, AltGr, Control, Control+Shift, Alt and Control+Alt maps, that
142 is, 7 columns instead of 256.) When no such line is given, the keymaps
143 0-M will be defined, where M+1 is the maximum number of entries found
144 in any definition line.
145
146 Next, you can leave off any trailing VoidSymbol entries from a key def‐
147 inition line. VoidSymbol denotes a keyboard action which produces no
148 output and has no other effects either. For example, to define key num‐
149 ber 30 to output 'a' unshifted, 'A' when pressed with Shift and do
150 nothing when pressed with AltGr or other modifiers, you can write
151
152 keycode 30 = a A
153
154 instead of the more verbose
155
156 keycode 30 = a A VoidSymbol VoidSymbol \
157 VoidSymbol VoidSymbol VoidSymbol ...
158
159 For added convenience, you can usually get off with still more terse
160 definitions. If you enter a key definition line with only and exactly
161 one action code after the equals sign, it has a special meaning. If the
162 code (numeric or symbolic) is not an ASCII letter, it means the code is
163 implicitly replicated through all columns being defined. If, on the
164 other hand, the action code is an ASCII character in the range 'a',
165 ..., 'z' or 'A', ..., 'Z' in the ASCII collating sequence, the follow‐
166 ing definitions are made for the different modifier combinations, pro‐
167 vided these are actually being defined. (The table lists the two pos‐
168 sible cases: either the single action code is a lower case letter,
169 denoted by 'x' or an upper case letter, denoted by 'Y'.)
170
171 modifier symbol
172
173 none x Y
174 Shift X y
175 AltGr x Y
176 Shift+AltGr X y
177 Control Control_x Control_y
178 Shift+Control Control_x Control_y
179 AltGr+Control Control_x Control_y
180 Shift+AltGr+Control Control_x Control_y
181 Alt Meta_x Meta_Y
182 Shift+Alt Meta_X Meta_y
183 AltGr+Alt Meta_x Meta_Y
184 Shift+AltGr+Alt Meta_X Meta_y
185 Control+Alt Meta_Control_x Meta_Control_y
186 Shift+Control+Alt Meta_Control_x Meta_Control_y
187 AltGr+Control+Alt Meta_Control_x Meta_Control_y
188 Shift+AltGr+Control+Alt Meta_Control_x Meta_Control_y
189
191 All the previous forms of key definition lines always define all the
192 M+1 possible modifier combinations being defined, whether the line
193 actually contains that many action codes or not. There is, however, a
194 variation of the definition syntax for defining only single actions to
195 a particular modifier combination of a key. This is especially useful,
196 if you load a keymap which doesn't match your needs in only some modi‐
197 fier combinations, like AltGr+function keys. You can then make a small
198 local file redefining only those modifier combinations and loading it
199 after the main file. The syntax of this form is:
200
201 { plain | <modifier sequence> } keycode keynumber = keysym
202
203 , e.g.,
204 plain keycode 14 = BackSpace
205 control alt keycode 83 = Boot
206 alt keycode 105 = Decr_Console
207 alt keycode 106 = Incr_Console
208 Using "plain" will define only the base entry of a key (i.e. the one
209 with no modifiers in effect) without affecting the bindings of other
210 modifier combinations of that key.
211
213 In addition to comments and key definition lines, a keymap can contain
214 string definitions. These are used to define what each function key
215 action code sends. The syntax of string definitions is:
216
217 string keysym = "text"
218
219 text can contain literal characters, octal character codes in the for‐
220 mat of backslash followed by up to three octal digits, and the three
221 escape sequences \n, \\, and \", for newline, backslash and quote,
222 respectively.
223
225 Then there may also be compose definitions. They have syntax
226
227 compose 'char' 'char' to 'char'
228 and describe how two bytes are combined to form a third one (when a
229 dead accent or compose key is used). This is used to get accented let‐
230 ters and the like on a standard keyboard.
231
233 Various abbreviations can be used with kbd-0.96 and later.
234
235 strings as usual
236 Defines the usual values of the strings (but not the keys they
237 are bound to).
238
239 compose as usual for "iso-8859-1"
240 Defines the usual compose combinations.
241
242 To find out what keysyms there are available for use in keymaps, use
243 the command
244
245 dumpkeys --long-info
246
247 Unfortunately, there is currently no description of what each symbol
248 does. It has to be guessed from the name or figured out from the kernel
249 sources.
250
252 (Be careful to use a keymaps line, like the first line of `dumpkeys`,
253 or "keymaps 0-15" or so.)
254
255 The following entry exchanges the left Control key and the Caps Lock
256 key on the keyboard:
257
258 keycode 58 = Control
259 keycode 29 = Caps_Lock
260
261 Key number 58 is normally the Caps Lock key, and key number 29 is nor‐
262 mally the Control key.
263
264 The following entry sets the Shift and Caps Lock keys to behave more
265 nicely, like in older typewriters. That is, pressing Caps Lock key once
266 or more sets the keyboard in CapsLock state and pressing either of the
267 Shift keys releases it.
268
269 keycode 42 = Uncaps_Shift
270 keycode 54 = Uncaps_Shift
271 keycode 58 = Caps_On
272
273 The following entry sets the layout of the edit pad in the enhanced
274 keyboard to be more like that in the VT200 series terminals:
275
276 keycode 102 = Insert
277 keycode 104 = Remove
278 keycode 107 = Prior
279 shift keycode 107 = Scroll_Backward
280 keycode 110 = Find
281 keycode 111 = Select
282 control alt keycode 111 = Boot
283 control altgr keycode 111 = Boot
284
285 Here's an example to bind the string "du\ndf\n" to the key AltGr-D. We
286 use the "spare" action code F100 not normally bound to any key.
287
288 altgr keycode 32 = F100
289 string F100 = "du\ndf\n"
290
292 loadkeys(1), dumpkeys(1), showkey(1), xmodmap(1)
293
294
295
296kbd 24 April 1998 KEYMAPS(5)