1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
|
.\" keymaps.5 - Copyright (C) Andries Brouwer 1998
.\" May be freely distributed.
.\" @(#)keymaps.5 1.10 940130 aeb
.TH KEYMAPS 5 "24 April 1998" "kbd"
.SH NAME
keymaps \- keyboard table descriptions for loadkeys and dumpkeys
.SH DESCRIPTION
.IX "keymaps" "" "\fLkeymaps\fR \(em keyboard table descriptions for loadkeys and dumpkeys" ""
.IX "loadkeys" "keyboard table descriptions" "\fLloadkeys\fR" "keyboard table descriptions"
.IX "dumpkeys" "keyboard table descriptions" "\fLdumpkeys\fR" "keyboard table descriptions"
.IX keyboard "table descriptions for loadkeys and dumpkeys" keyboard "table descriptions for \fLloadkeys\fR and \fLdumpkeys\fR"
.IX "translation tables"
.LP
These files are used by
.BR loadkeys (1)
to modify the translation tables used by the kernel keyboard driver
and generated by
.BR dumpkeys (1)
from those translation tables.
.LP
The format of these files is vaguely similar to the one accepted by
.BR xmodmap (1).
The file consists of charset or key or string definition lines
interspersed with comments.
.LP
Comments are introduced with
.B !
or
.B #
characters and continue to the end of the line. Anything following one
of these characters on that line is ignored. Note that comments need
not begin from column one as with
.BR xmodmap (1).
.LP
The syntax of keymap files is line oriented; a complete definition
must fit on a single logical line. Logical lines can, however, be split
into multiple physical lines by ending each subline with the backslash
character (\\).
.SH "INCLUDE FILES"
A keymap can include other keymaps using the syntax
.LP
.RS
include "pathname"
.RE
.LP
.SH "CHARSET DEFINITIONS"
A character set definition line is of the form:
.LP
.RS
.EX
charset "iso-8859-x"
.EE
.RE
.LP
It defines how following keysyms are to be interpreted.
For example, in iso-8859-1 the symbol mu (or micro) has code 0265,
while in iso-8859-7 the letter mu has code 0354.
.SH "COMPLETE KEYCODE DEFINITIONS"
Each complete key definition line is of the form:
.LP
.RS
.nf
.BI keycode " keynumber " = " keysym keysym keysym" \fR...
.fi
.RE
.LP
.I keynumber
is the internal identification number of the key, roughly equivalent to
the scan code of it.
.I keynumber
can be given in decimal, octal or hexadecimal notation.
Octal is denoted by a leading zero and hexadecimal by the prefix
.B 0x.
.LP
Each of the
.I keysyms
represent keyboard actions, of which up to 256 can be bound to a single
key. The actions available include outputting character codes or
character sequences, switching consoles or keymaps, booting the machine
etc. (The complete list can be obtained from
.BR dumpkeys (1)
by saying
.B " dumpkeys -l"
\&.)
.LP
Each
.I keysym
may be prefixed by a '+' (plus sign), in wich case this keysym is treated
as a "letter" and therefore affected by the "CapsLock" the same way as by
"Shift" (to be correct, the CapsLock inverts the Shift state).
The ASCII letters ('a'-'z' and 'A'-'Z') are made CapsLock'able by default.
If Shift+CapsLock should not produce a lower case symbol, put lines like
.LP
.RS
.nf
.B "keycode 30 = +a A"
.fi
.RE
.LP
in the map file.
.LP
Which of the actions bound to a given key is taken when it is pressed
depends on what modifiers are in effect at that moment.
The keyboard driver supports 9 modifiers. These modifiers are labeled
(completely arbitrarily) Shift, AltGr, Control, Alt, ShiftL, ShiftR,
CtrlL, CtrlR and CapsShift.
Each of these modifiers has an associated weight of power of two
according to the following table:
.ev table
.LP
.RS
.TP 20
.I modifier
.I weight
.P
.ta T 24R
Shift 1
.br
AltGr 2
.br
Control 4
.br
Alt 8
.br
ShiftL 16
.br
ShiftR 32
.br
CtrlL 64
.br
CtrlR 128
.br
CapsShift 256
.RE
.LP
.ev
The effective action of a key is found out by adding up the weights of
all the modifiers in effect. By default, no modifiers are in effect, so
action number zero, i.e. the one in the first column in a key definition
line, is taken when the key is pressed or released. When e.g. Shift and
Alt modifiers are in effect, action number nine (from the 10th column)
is the effective one.
.LP
Changing the state of what modifiers are in effect can be achieved by
binding appropriate key actions to desired keys. For example, binding
the symbol Shift to a key sets the Shift modifier in effect when that
key is pressed and cancels the effect of that modifier when the key is
released. Binding AltGr_Lock to a key sets AltGr in effect when the key
is pressed and cancels the effect when the key is pressed again.
(By default Shift, AltGr, Control and Alt are bound to the keys that bear
a similar label; AltGr may denote the right Alt key.)
.LP
Note that you should be very careful when binding the modifier keys,
otherwise you can end up with an unusable keyboard mapping. If you for
example define a key to have Control in its first column and leave the
rest of the columns to be VoidSymbols, you're in trouble. This is
because pressing the key puts Control modifier in effect and the
following actions are looked up from the fifth column (see the table
above). So, when you release the key, the action from the fifth column
is taken. It has VoidSymbol in it, so nothing happens. This means that
the Control modifier is still in effect, although you have released the key.
Re-pressing and releasing the key has no effect. To avoid this,
you should always define all the columns to have the same modifier
symbol. There is a handy short-hand notation for this, see below.
.LP
.I keysyms
can be given in decimal, octal, hexadecimal, unicode or symbolic notation.
The numeric notations use the same format as with
.IR keynumber .
Unicode notation is "U+" followed by four hexadecimal digits.
The symbolic notation resembles that used by
.BR xmodmap (1).
Notable differences are the number symbols. The numeric
symbols '0', ..., '9' of
.BR xmodmap (1)
are replaced with the corresponding words 'zero', 'one', ... 'nine' to
avoid confusion with the numeric notation.
.LP
It should be noted that using numeric notation for the
.I keysyms
is highly unportable as the key action numbers may vary from one kernel
version to another and the use of numeric notations is thus strongly
discouraged. They are intended to be used only when you know there is a
supported keyboard action in your kernel for which your current version
of
.BR loadkeys (1)
has no symbolic name.
.LP
There is a number of short-hand notations to add readability and reduce
typing work and the probability of typing-errors.
.LP
First of all, you can give a map specification line, of the form
.LP
.RS
.EX
keymaps 0-2,4-5,8,12
.EE
.RE
.LP
to indicate that the lines of the keymap will not specify all 256 columns,
but only the indicated ones. (In the example: only the plain, Shift,
AltGr, Control, Control+Shift, Alt and Control+Alt maps, that is, 7 columns
instead of 256.)
When no such line is given, the keymaps 0-M will be defined, where
M+1 is the maximum number of entries found in any definition line.
.LP
Next, you can leave off any trailing VoidSymbol entries from a key
definition line. VoidSymbol denotes a keyboard action which produces no
output and has no other effects either. For example, to define key
number 30 to output 'a' unshifted, 'A' when pressed with Shift and do
nothing when pressed with AltGr or other modifiers, you can write
.LP
.RS
.nf
keycode 30 = a A
.fi
.RE
.LP
instead of the more verbose
.LP
.RS
.nf
keycode 30 = a A VoidSymbol VoidSymbol \\
VoidSymbol VoidSymbol VoidSymbol ...
.fi
.RE
.LP
For added convenience, you can usually get off with still more terse
definitions. If you enter a key definition line with only and exactly
one action code after the equals sign, it has a special meaning. If the
code (numeric or symbolic) is not an ASCII letter, it means the code
is implicitly replicated through all columns being defined.
If, on the other hand, the action code is an ASCII character in the
range 'a', ..., 'z' or 'A', ..., 'Z' in the ASCII collating sequence,
the following definitions are made for the different modifier combinations,
provided these are actually being defined.
(The table lists the two possible cases:
either the single action code is a lower case letter,
denoted by 'x' or an upper case letter, denoted by 'Y'.)
.LP
.RS 4
.TP 24
.I modifier
.I symbol
.TP 24
none
x Y
.PD 0
.TP 24
Shift
X y
.TP 24
AltGr
x Y
.TP 24
Shift+AltGr
X y
.TP 24
Control
Control_x Control_y
.TP 24
Shift+Control
Control_x Control_y
.TP 24
AltGr+Control
Control_x Control_y
.TP 24
Shift+AltGr+Control
Control_x Control_y
.TP 24
Alt
Meta_x Meta_Y
.TP 24
Shift+Alt
Meta_X Meta_y
.TP 24
AltGr+Alt
Meta_x Meta_Y
.TP 24
Shift+AltGr+Alt
Meta_X Meta_y
.TP 24
Control+Alt
Meta_Control_x Meta_Control_y
.TP 24
Shift+Control+Alt
Meta_Control_x Meta_Control_y
.TP 24
AltGr+Control+Alt
Meta_Control_x Meta_Control_y
.TP 24
Shift+AltGr+Control+Alt
Meta_Control_x Meta_Control_y
.PD
.RE
.LP
.SH "SINGLE MODIFIER DEFINITIONS"
All the previous forms of key definition lines always define all the M+1
possible modifier combinations being defined, whether the line actually
contains that many action codes or not.
There is, however, a variation of the definition
syntax for defining only single actions to a particular modifier
combination of a key. This is especially useful, if you load a keymap
which doesn't match your needs in only some modifier combinations, like
AltGr+function keys. You can then make a small local file redefining
only those modifier combinations and loading it after the main file.
The syntax of this form is:
.LP
.BR "" { " plain " "| <modifier sequence> } " keycode
.I keynumber
.B =
.I keysym
.LP
, e.g.,
.RS
.EX
.nf
plain keycode 14 = BackSpace
control alt keycode 83 = Boot
alt keycode 105 = Decr_Console
alt keycode 106 = Incr_Console
.fi
.EE
.RE
Using "plain" will define only the base entry of a
key (i.e. the one with no modifiers in effect) without affecting the
bindings of other modifier combinations of that key.
.SH "STRING DEFINITIONS"
In addition to comments and key definition lines, a keymap can
contain string definitions. These are used to define what each function
key action code sends. The syntax of string definitions is:
.LP
.RS
.B string
.I keysym
.B =
.BI """" text """"
.RE
.LP
.I text
can contain literal characters, octal character codes in the format of
backslash followed by up to three octal digits, and the three escape
sequences \fB\\n\fP, \fB\\\\\fP, and \fB\\"\fP,
for newline, backslash and quote, respectively.
.SH "COMPOSE DEFINITIONS"
Then there may also be compose definitions. They have syntax
.LP
.RS
.BI "compose '" char "' '" char "' to '" char "'"
.RE
and describe how two bytes are combined to form a third one
(when a dead accent or compose key is used).
This is used to get accented letters and the like on a standard
keyboard.
.SH ABBREVIATIONS
Various abbreviations can be used with kbd-0.96 and later.
.TP
.B "strings as usual"
Defines the usual values of the strings (but not the keys
they are bound to).
.TP
\fBcompose as usual for "iso-8859-1"\fP
Defines the usual compose combinations.
.LP
To find out what
.I keysyms
there are available for use in keymaps, use the command
.LP
.RS
.nf
.B dumpkeys --long-info
.fi
.RE
.LP
Unfortunately, there is currently no description of what each symbol
does. It has to be guessed from the name or figured out from the kernel
sources.
.LP
.SH EXAMPLES
(Be careful to use a keymaps line, like the first line of `dumpkeys`,
or "keymaps 0-15" or so.)
.LP
The following entry exchanges the left Control key and the Caps Lock
key on the keyboard:
.LP
.RS
.nf
keycode 58 = Control
keycode 29 = Caps_Lock
.fi
.RE
.LP
Key number 58 is normally the Caps Lock key, and key number 29 is
normally the Control key.
.LP
The following entry sets the Shift and Caps Lock keys to behave more
nicely, like in older typewriters. That is, pressing Caps Lock key once
or more sets the keyboard in CapsLock state and pressing either of the
Shift keys releases it.
.LP
.RS
.nf
keycode 42 = Uncaps_Shift
keycode 54 = Uncaps_Shift
keycode 58 = Caps_On
.fi
.RE
.LP
The following entry sets the layout of the edit pad in the enhanced
keyboard to be more like that in the VT200 series terminals:
.LP
.RS
.nf
keycode 102 = Insert
keycode 104 = Remove
keycode 107 = Prior
shift keycode 107 = Scroll_Backward
keycode 110 = Find
keycode 111 = Select
control alt keycode 111 = Boot
control altgr keycode 111 = Boot
.fi
.RE
.LP
Here's an example to bind the string "du\\ndf\\n" to the key AltGr-D. We use
the "spare" action code F100 not normally bound to any key.
.LP
.RS
.nf
altgr keycode 32 = F100
string F100 = "du\\ndf\\n"
.RE
.LP
.SH "SEE ALSO"
.BR loadkeys (1),
.BR dumpkeys (1),
.BR showkey (1),
.BR xmodmap (1)
|