Debian Codegraph @

Documents/README.KeyTables

raw
1 ~~~~~~~~~~
2 Key Tables
3 ~~~~~~~~~~
4
5 .. include:: prologue.rst
6
7 Description
8 ===========
9
10 Files with names of the form ``*.ktb`` are key tables, and with names of the
11 form ``*.kti`` are key subtables. They are used to bind braille device and
12 computer keyboard key combinations to BRLTTY commands.
13
14 * Braille device key tables can usually be found in the
15 ``/etc/brltty/Input/xx/`` directory, where ``xx`` is the two-letter braille
16 driver identification code (see `Braille Driver List`_). The name of a
17 braille device key table identifies the model(s) for which it is used. The
18 driver selects which key table is to be used.
19
20 * Computer keyboard key tables can usually be found in the
21 ``/etc/brltty/Keyboard/`` directory. The name of a keyboard key table
22 describes the kind of keyboard for which it has been designed. See
23 `Keyboard Table List`_ for a list of BRLTTY's keyboard tables.
24
25 * See |README.Customize| for more details regarding key table locations.
26
27 A key table consists of a sequence of directives, one per line, which define
28 how keys and key combinations are to be interpreted. UTF-8 character encoding
29 must be used. Whitespace (blanks, tabs) at the beginning of a line, as well as
30 before and/or after any operand, is ignored. Lines containing only whitespace
31 are ignored. If the first non-whitespace character of a line is ``#`` then
32 that line is a comment and is ignored.
33
34 The precedence for resolving each key press/release event is as follows:
35
36 1) A hotkey press or release defined within the current context.
37 2) A key combination defined within the current context.
38 3) A braille keyboard command defined within the current context.
39 4) A key combination defined within the default context.
40
41 Directives
42 ==========
43
44 .. |key operand| replace::
45 The name of the key whose availability is to be tested.
46
47 .. |platform operand| replace::
48 The name of a host platform.
49 The following platform names are recognized:
50 android, apple, cygwin, dos, grub, linux,
51 mingw32, mingw64, openbsd, sun, windows.
52
53 The Bind Directive
54 ------------------
55
56 .. parsed-literal:: bind *keys* *commands*
57
58 Use this directive to define which BRLTTY command is executed when a particular
59 combination of keys is pressed. The binding is defined within the current
60 context.
61
62 *keys*
63 The key combination which is to be bound. It's a sequence of one or more key
64 and/or key group names separated by plus (``+``) signs. The final (or only)
65 key name may be optionally prefixed with an exclamation (``!``) point. For
66 example::
67
68 key1
69 group1
70 key1+key2
71 key1+key2+group1
72 !group1
73 key1+!key2
74
75 A key group name refers to any key within the named group. A specific key
76 within the group may be identified by appending a dot (``.``) and a number
77 to the group's name. The first key within a group is key #1 (e.g.
78 ``keyGroupName.1``).
79
80 The keys may be pressed in any order, with the exception that if the final
81 key name is prefixed with an exclamation point then it must be pressed last.
82 The exclamation point prefix means that the primary command (see below) is
83 executed as soon as that key is pressed. If not used, the primary command is
84 executed as soon as any of the keys is released.
85
86 *commands*
87 The primary and secondary BRLTTY commands that are to be bound to the key
88 combination. The two commands (primary first and secondary last) are
89 separated from one another by a colon (``:``). Both commands are optional.
90 If just a primary command is being bound then the colon needn't be supplied.
91 All of these are valid:
92
93 * bind key primaryCommand
94 * bind key primaryCommand:
95 * bind key primaryCommand:secondaryCommand
96 * bind key :secondaryCommand
97 * bind key :
98
99 The primary command is executed as described above. The secondary command is
100 executed if the key combination is held for a while (i.e. when a long key
101 press is detected). If the **autorepeat** feature is enabled then the
102 secondary command is autorepeated if it has been defined, else the primary
103 command is autorepeated.
104
105 For a list of commands, see |README.CommandReference|.
106
107 .. _Bind Command Modifiers:
108
109 One or more modifiers may be optionally appended to a command name by using a
110 plus (``+``) sign as the separator. For example::
111
112 bind key command
113 bind key command+modifier1
114 bind key command+modifier1+modifier2
115
116 For commands which enable/disable a feature:
117
118 * If the modifier ``+on`` is specified then the feature is enabled.
119 * If the modifier ``+off`` is specified then the feature is disabled.
120 * If neither ``+on`` nor ``+off`` is specified then the state of the feature
121 is toggled on/off.
122
123 For commands which move the braille window:
124
125 * If the modifier ``+route`` is specified then, if necessary, the screen
126 cursor is automatically routed so that it's always visible on the braille
127 display.
128
129 For commands which move the braille window to a specific line on the screen:
130
131 * If the modifier ``+toleft`` is specified then the braille window is also
132 moved to the beginning of that line.
133 * If the modifier ``+scaled`` is specified then the key group bound to the
134 command is interpreted as though it were a scroll bar. If it isn't
135 specified then there's a one-to-one correspondence between keys and lines.
136
137 For commands which require an offset:
138
139 * The modifier ``+offset``, where ``offset`` is a non-negative integer, may be
140 specified. If it isn't specified then ``+0`` is assumed.
141
142 For commands which input any keyboard key (print or braille):
143
144 * The ``+shift`` modifier adds the shift key.
145 * The ``+control`` modifier adds the control key.
146 * The ``+meta`` modifier adds the left alt (or meta) key.
147 * The ``+altgr`` modifier adds the right alt (or altgr) key.
148 * The ``+gui`` modifier adds the gui (or windows) key.
149
150 For commands which input characters (print or braille):
151
152 * The modifier ``+upper`` converts a lowercase character to uppercase.
153
154 For commands which input braille characters:
155
156 * The modifiers ``+dot1`` through ``+dot8`` add those dots to the character.
157 * The modifier ``+space`` adds the space bar (or "chord" key) to the
158 character.
159
160 For commands which input keyboard scancodes:
161
162 * The ``+release`` modifier means that it's a key release scancode. If it
163 isn't specified then it's a key press scancode (unless, of course, the
164 scancode itself indicates something else).
165 * The ``+emul0`` modifier means that it's an emulation mode 0 scancode.
166 * The ``+emul1`` modifier means that it's an emulation mode 1 scancode.
167
168 Examples::
169
170 bind Key1 CSRTRK
171 bind Key1+Key2 CSRTRK+off
172 bind Key1+Key3 CSRTRK+on
173 bind Key4 TOP
174 bind Key5 TOP+route
175 bind VerticalSensor GOTOLINE+toleft+scaled
176 bind Key6 CONTEXT+context1
177
178 The Context Directive
179 ---------------------
180
181 .. parsed-literal:: context *name* *title*
182
183 Use this directive to define alternate ways to interpret certain key events
184 and/or combinations.
185 Switching to another context is done via the BRLTTY command CONTEXT+name.
186
187 A context contains definitions created by any of:
188
189 * `The Bind Directive`_
190 * `The Hotkey Directive`_
191 * `The Ignore Directive`_
192 * `The Macro Directive`_
193 * `The Map Directive`_
194 * `The Run Directive`_
195 * `The Superimpose Directive`_
196
197 *name*
198 Which context subsequent definitions are to be created within.
199
200 *title*
201 A person-readable description of the context. It may contain spaces.
202 Standard capitalization conventions should be used. This operand is
203 optional. If supplied when selecting a context which already has a title
204 then the two must match. Special contexts already have internally-assigned
205 titles.
206
207 A context is created the first time it's selected. It may be reselected any
208 number of times thereafter. These special contexts are predefined:
209
210 ``default``
211 The default context. If a definition can't be found within the current
212 context then it's looked up within the default context. This only applies
213 to definitions created by:
214
215 * `The Bind Directive`_.
216 * `The Macro Directive`_.
217 * `The Run Directive`_.
218
219 ``menu``
220 This context is used when within BRLTTY's Preferences Menu.
221
222 All subsequent definitions until either the next ``context`` directive or the
223 end of the current include level are created within the selected context. The
224 initial context of the top-level key table is ``default``. The initial context
225 of an included key subtable is the context which was selected when it was
226 included. Context changes within included key subtables don't affect the
227 context of the including key table or subtable.
228
229 If a context has a title then it is persistent. When a key event causes a
230 persistent context to be activated, that context remains current until a
231 subsequent key event causes a different persistent context to be activated.
232
233 If a context doesn't have a title then it is temporary. When a key event causes
234 a temporary context to be activated, that context is only used to interpret the
235 very next key event.
236
237 Examples::
238
239 context menu
240 context braille Braille Input
241 context DESCCHAR
242
243 The Hide Directive
244 ------------------
245
246 .. parsed-literal:: hide *state*
247
248 Use this directive to specify whether or not definitions created by:
249
250 * `The Bind Directive`_
251 * `The Hotkey Directive`_
252 * `The Map Directive`_
253 * `The Superimpose Directive`_
254
255 and text added by:
256
257 * `The Note Directive`_
258
259 are to be included within the key table's help text.
260
261 *state*
262 One of these keywords:
263
264 ``on``
265 They're excluded.
266 ``off``
267 They're included.
268
269 The specified hide state applies to all subsequent definitions and notes until
270 either the next ``hide`` directive or the end of the current include level. The
271 initial hide state of the top-level key table is ``off``. The initial hide
272 state of an included key subtable is the hide state that was in effect when it
273 was included. Hide State changes within included key subtables don't affect the
274 hide state of the including key table or subtable.
275
276 Examples::
277
278 hide on
279
280 The Hotkey Directive
281 --------------------
282
283 .. parsed-literal:: hotkey *key* *press* *release*
284
285 Use this directive to bind the press and release events of a specific key to
286 two separate BRLTTY commands. The bindings are defined within the current
287 context.
288
289 *key*
290 The name of the key which is to be bound.
291
292 *press*
293 The name of the BRLTTY command which is to be executed whenever the key is
294 pressed.
295
296 *release*
297 The name of the BRLTTY command which is to be executed whenever the key is
298 released.
299
300 Modifiers may be appended to the command names. See
301 `Bind Command Modifiers`_ for details.
302
303 Specify the ``NOOP`` command if no command is to be executed. Specifying the
304 ``NOOP`` command for both events effectively disables the key.
305
306 Examples::
307
308 hotkey Key1 CSRVIS+off CSRVIS+on
309 hotkey Key2 NOOP NOOP
310
311 The IfKey Directive
312 -------------------
313
314 .. parsed-literal:: ifKey *key* *directive*
315
316 Use this directive to only process one or more directives if the device has a
317 particular key.
318
319 *key*
320 |key operand|
321
322 *directive*
323 |directive operand|
324
325 Examples::
326
327 ifKey Key1 ifkey Key2 bind Key1+Key2 HOME
328
329 The IfNotKey Directive
330 ----------------------
331
332 .. parsed-literal:: ifNotKey *key* *directive*
333
334 Use this directive to only process one or more directives if the device doesn't
335 have a particular key.
336
337 *key*
338 |key operand|
339
340 *directive*
341 |directive operand|
342
343 Examples::
344
345 ifNotKey Key2 bind Key1 HOME
346
347 The IfPlatform Directive
348 ------------------------
349
350 .. parsed-literal:: ifPlatform *platform* *directive*
351
352 Use this directive to only process one or more directives if running on the
353 named host platform.
354
355 *platform*
356 |platform operand|
357
358 *directive*
359 |directive operand|
360
361 Examples::
362
363 ifPlatform android include android.kti
364
365 The IfNotPlatform Directive
366 ---------------------------
367
368 .. parsed-literal:: ifNotPlatform *platform* *directive*
369
370 Use this directive to only process one or more directives if not running on
371 the named host platform.
372
373 *platform*
374 |platform operand|
375
376 *directive*
377 |directive operand|
378
379 Examples::
380
381 ifNotPlatform grub include advanced.kti
382
383 The Ignore Directive
384 --------------------
385
386 .. parsed-literal:: ignore *key*
387
388 Use this directive to ignore a specific key while within the current context.
389
390 *key*
391 The name of the key which is to be ignored.
392
393 Examples::
394
395 ignore Key1
396
397 The Isolated Directive
398 ----------------------
399
400 .. parsed-literal:: isolated
401
402 Use this directive to isolate the current context.
403 If a key binding can't be found within an isolated context
404 then it won't be looked up within the default context.
405
406 Examples::
407
408 isolated
409
410 The Macro Directive
411 -------------------
412
413 .. parsed-literal:: macro *keys* *command* ...
414
415 Use this directive to bind a sequence of BRLTTY commands to a key combination.
416
417 *keys*
418 The key combination being defined.
419
420 *command* ...
421 The BRLTTY commands that are to be executed.
422
423 Examples::
424
425 macro Key1+Key2 TOP LNEND
426
427 The Map Directive
428 -----------------
429
430 .. parsed-literal:: map *key* *function*
431
432 Use this directive to map a key to a braille keyboard function. The mapping is
433 defined within the current context.
434
435 *key*
436 The name of the key that is to be mapped. More than one key may be mapped to
437 the same braille keyboard function.
438
439 .. _The Map Function Operand:
440
441 *function*
442 The name of the braille keyboard function. It may be one of the following
443 keywords:
444
445 ``DOT1``
446 The upper-left standard braille dot key.
447 ``DOT2``
448 The middle-left standard braille dot key.
449 ``DOT3``
450 The lower-left standard braille dot key.
451 ``DOT4``
452 The upper-right standard braille dot key.
453 ``DOT5``
454 The middle-right standard braille dot key.
455 ``DOT6``
456 The lower-right standard braille dot key.
457 ``DOT7``
458 The lower-left computer braille dot key.
459 ``DOT8``
460 The lower-right computer braille dot key.
461 ``SPACE``
462 The space bar.
463 ``SHIFT``
464 The shift key.
465 ``UPPER``
466 If a lowercase letter is being entered then translate it to its
467 uppercase equivalent.
468 ``CONTROL``
469 The control key.
470 ``META``
471 The left alt (or meta) key.
472 ``ALTGR``
473 The right alt (or altgr) key.
474 ``GUI``
475 The gui (or windows) key.
476
477 If a key combination consists only of keys which have been mapped to braille
478 keyboard functions, and if those functions, when combined, form a valid braille
479 keyboard command, then that command is executed as soon as any of the keys is
480 released. A valid braille keyboard command must include either any combination
481 of dot keys or the space bar (but not both). If at least one dot key is
482 included then the braille keyboard functions specified by
483 `The Superimpose Directive`_ within the same context are also implicitly
484 included.
485
486 Examples::
487
488 map Key1 DOT1
489
490 The Note Directive
491 ------------------
492
493 .. parsed-literal:: note *text*
494
495 Use this directive to add a person-readable explanation to the key table's help
496 text. Notes are commonly used, for example, to describe the placement, sizes,
497 and shapes of the keys on the device.
498
499 *text*
500 The explanation that is to be added. It may contain spaces, and should be
501 grammatically correct.
502
503 Each note specifies exactly one line of explanatory text. Leading space is
504 ignored so indentation cannot be specified.
505
506 There's no limit to the number of notes that may be added. All of them are
507 gathered together and presented in a single block at the start of the key
508 table's help text.
509
510 * A note that doesn't have a special prefix begins a new outer bulleted list
511 element.
512
513 * A note that is prefixed with an asterisk (``*``) continues the current outer
514 bulleted list element.
515
516 * A note that is prefixed with a plus (``+``) sign is an inner bulleted list
517 element.
518
519 Examples::
520
521 note This is the first outer list element.
522 note This is the second outer list element.
523 note * Continue the second outer list element.
524 note + The first element of an inner list.
525 note + The second element of an inner list.
526 note * The third line of the second outer list element.
527
528 The above example would be rendered as:
529
530 * This is the first outer list element.
531
532 * This is the second outer list element.
533 Continue the second outer list element.
534
535 + The first element of an inner list.
536
537 + The second element of an inner list.
538
539 The third line of the second outer list element.
540
541 The Run Directive
542 -----------------
543
544 .. parsed-literal:: run *keys* *name* [*argument* ...]
545
546 Use this directive to bind a host command to a key combination.
547
548 *keys*
549 The key combination being defined.
550
551 <name*
552 The name of the host command. It may also be the path.
553
554 *argument* ...
555 The arguments to be passed to the host command.
556
557 Examples::
558
559 run Key1+Key2 pkill --exact brltty
560
561 The Superimpose Directive
562 -------------------------
563
564 .. parsed-literal:: superimpose *function*
565
566 Use this directive to implicitly include a braille keyboard function whenever a
567 braille keyboard command consisting of at least one dot is executed. Only
568 implicit inclusions defined within the current context are performed. Any
569 number of these directives may be specified.
570
571 *function*
572 The name of the braille keyboard function that is to be implicitly included.
573 See `The Map Function Operand`_ for details.
574
575 Examples::
576
577 superimpose DOT7
578
579 The Title Directive
580 -------------------
581
582 .. parsed-literal:: title <text>
583
584 Use this directive to specify a person-readable, one-line summary of the key
585 table's purpose.
586
587 *text*
588 A brief summary of what the key table is used for. It may contain spaces,
589 and standard capitalization conventions should be used.
590
591 The title of the key table may be specified only once.
592
593 Examples::
594
595 title Bindings for Keypad-based Navigation
596
597 .. include:: nesting-directives.rst
598 .. include:: variable-directives.rst
599 .. include:: condition-directives.rst
600
601 Keyboard Table List
602 ===================
603
604 .. csv-table::
605 :header-rows: 1
606 :file: keyboard-table.csv
607
608 Braille Driver List
609 ===================
610
611 .. csv-table::
612 :header-rows: 1
613 :file: braille-driver.csv
614