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