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