libkeymap: Do not dump diacr values if lk_dump_keymap called
[platform/upstream/kbd.git] / doc / kbd.FAQ.txt
1   The Linux keyboard and console HOWTO
2   Andries Brouwer, aeb@cwi.nl
3   v2.9, 990114
4
5   This note contains some information about the Linux keyboard and con-
6   sole, and the use of non-ASCII characters.  It describes Linux 2.0.
7   ______________________________________________________________________
8
9   Table of Contents
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   1. Useful programs
68
69   2. Keyboard generalities
70
71   3. Console generalities
72
73   4. Resetting your terminal
74
75      4.1 Keyboard hardware reset
76
77   5. Delete and Backspace
78
79      5.1 How to tell Unix what character you want to use to delete the last typed character
80         5.1.1 `Getty used to do the right thing with DEL and BS but is broken now?'
81         5.1.2 `Login behaves differently at the first and second login attempts?'
82      5.2 How to tell Linux what code to generate when a key is pressed
83         5.2.1 `How do I get a dvorak keyboard?'
84         5.2.2 `Why doesn't the Backspace key generate BackSpace by default?'
85      5.3 How to tell X to interchange Delete and Backspace
86      5.4 How to tell emacs what to do when it receives a Delete or Backspace
87      5.5 How to tell emacs to interchange Delete and Backspace
88      5.6 How to tell kermit to interchange Delete and Backspace
89      5.7 How to tell xterm to interchange Delete and Backspace
90      5.8 How to tell xterm about your favourite tty modes
91      5.9 How to tell xmosaic that the Backspace key generates a DEL
92      5.10 A better solution for Motif-using programs, like netscape
93      5.11 What about termcap and terminfo?
94      5.12 A complete solution
95
96   6. The console character sets
97
98   7. Console switching
99
100      7.1 Changing the number of Virtual Consoles
101
102   8. Ctrl-Alt-Del and other special key combinations
103
104      8.1 Ctrl-Alt-Del (Boot)
105      8.2 Other combinations
106      8.3 X Combinations
107      8.4 Dosemu Combinations
108      8.5 Composing symbols
109      8.6 The SysRq key
110
111   9. How to get out of raw mode
112
113   10. The keyboard LEDs
114
115   11. The TERM variable
116
117      11.1 Terminfo
118
119   12. How to make other programs work with non-ASCII chars
120
121   13. X
122
123      13.1 What precisely does XFree86-2.1 do when it initializes its keymap?
124
125   14. Unusual keys and keyboards
126
127   15. Examples of use of loadkeys and xmodmap
128
129      15.1 `I can use only one finger to type with'
130
131   16. Changing the video mode
132
133      16.1 Instructions for the use of resizecons
134
135   17. Changing the keyboard repeat rate
136
137   18. Scrolling
138
139   19. Screensaving
140
141   20. Screen dumps
142
143   21. Some properties of the VT100 - application key mode
144
145   22. Hardware incompatibility
146
147   23. Copyright
148
149
150
151   ______________________________________________________________________
152
153   1\b1.\b.  U\bUs\bse\bef\bfu\bul\bl p\bpr\bro\bog\bgr\bra\bam\bms\bs
154
155
156   The following packages contain keyboard or console related programs.
157
158   kbd-1.00.tar.gz contains loadkeys, dumpkeys, showkey, setmetamode,
159   setleds, setfont, showfont, mapscrn, kbd_mode, kbdrate, loadunimap,
160   chvt, resizecons, deallocvt, getkeycodes, setkeycodes.  It also
161   contains openvt, formerly called open.
162
163   SVGATextMode-1.8.tar.gz contains SVGATextMode, a program that
164   obsoletes resizecons.
165
166   util-linux-2.9 contains setterm, kbdrate.
167
168   sh-utils-1.12 contains stty.
169
170   See also dynamic-vc-1.1.tar.gz and consd-1.1.tgz for programs that
171   exploit the `Keyboard Signal' key. Very primitive versions are
172   spawn_login or spawn_console found in the kbd package.
173
174   See font.tgz for a package that handles console fonts.
175
176
177   The X distribution contains xmodmap, xset, kbd_mode.  (See also
178   X386keybd(1) for the situation under XFree86 1.3, and Xserver(1) for
179   the XKEYBOARD extension under X11R6.)  A handy interface to xmodmap is
180   xkeycaps, see http://www.jwz.org/xkeycaps/.
181
182   termcap-2.0.8.tar.gz contains termcap, an old terminal capabilities
183   data base. ncurses-1.9.9e.tar.gz contains the termlib data base which
184   obsoletes termcap. (However, there are still many programs using
185   termcap.)
186
187   See loadkeys(1), setleds(1) and setmetamode(1) for the codes generated
188   by the various keys and the setting of leds when not under X. Under X,
189   see xmodmap(1) and xset(1).
190
191   See setfont(8) for loading console fonts. Many people will want to
192   load a font like iso01.f16 because the default font is the hardware
193   font of the video card, and often is a `Code Page 437' font missing
194   accented characters and other Latin-1 symbols.
195
196   See setterm(1) and kbdrate(8) for properties such as foreground and
197   background colors, screen blanking and character repeat rate when not
198   under X.  Under X, see xset(1), also for key click and bell volume.
199   The file /etc/termcap defines the escape sequences used by many
200   programs addressing the console (or any other terminal).  See
201   termcap(5).  A more modern version is found in /usr/lib/terminfo.  See
202   terminfo(5). Terminfo files are compiled by the terminfo compiler
203   /usr/lib/terminfo/tic, see tic(1).  Their contents can be examined
204   using the program infocmp, see infocmp(1).
205
206   The Linux console sequences are documented in console_codes(4).
207
208
209
210
211   2\b2.\b.  K\bKe\bey\byb\bbo\boa\bar\brd\bd g\bge\ben\bne\ber\bra\bal\bli\bit\bti\bie\bes\bs
212
213
214   You press a key, and the keyboard controller sends scancodes to the
215   kernel keyboard driver. Some keyboards can be programmed, but usually
216   the scancodes corresponding to your keys are fixed.  The kernel
217   keyboard driver just transmits whatever it receives to the application
218   program when it is in _\bs_\bc_\ba_\bn_\bc_\bo_\bd_\be _\bm_\bo_\bd_\be, like when X is running.
219   Otherwise, it parses the stream of scancodes into keycodes,
220   corresponding to key press or key release events.  (A single key press
221   can generate up to 6 scancodes.)  These keycodes are transmitted to
222   the application program when it is in _\bk_\be_\by_\bc_\bo_\bd_\be _\bm_\bo_\bd_\be (as used, for
223   example, by showkey).  Otherwise, these keycodes are looked up in the
224   keymap, and the character or string found there is transmitted to the
225   application, or the action described there is performed.  (For
226   example, if one presses and releases the a key, then the keyboard
227   produces scancodes 0x1e and 0x9e, this is converted to keycodes 30 and
228   158, and then transmitted as 0141, the ASCII or latin-1 code for `a';
229   if one presses and releases Delete, then the keyboard produces
230   scancodes 0xe0 0x53 0xe0 0xd3, these are converted to keycodes 111 and
231   239, and then transmitted as the 4-symbol sequence ESC [ 3 ~, all
232   assuming a US keyboard and a default keymap. An example of a key
233   combination to which an action is assigned is Ctrl-Alt-Del.)
234
235   The translation between unusual scancodes and keycodes can be set
236   using the utility setkeycodes - only very few people will need it.
237   The translation between keycodes and characters or strings or actions,
238   that is, the keymap, is set using the utilities loadkeys and
239   setmetamode.  For details, see getkeycodes(8), setkeycodes(8),
240   dumpkeys(1), loadkeys(1), setmetamode(1). The format of the files
241   output by dumpkeys and read by loadkeys is described in keymaps(5).
242
243   Where it says `transmitted to the application' in the above
244   description, this really means `transmitted to the terminal driver'.
245   That is, further processing is just like that of text that comes in
246   over a serial line.  The details of this processing are set by the
247   program stty.
248
249
250   3\b3.\b.  C\bCo\bon\bns\bso\bol\ble\be g\bge\ben\bne\ber\bra\bal\bli\bit\bti\bie\bes\bs
251
252
253   Conversely, when you output something to the console, it first
254   undergoes the standard tty processing, and then is fed to the console
255   driver.  The console driver emulates a VT100, and parses the input in
256   order to recognize VT100 escape sequences (for cursor movement, clear
257   screen, etc.).  The characters that are not part of an escape sequence
258   are first converted into Unicode, using one of four mapping tables if
259   the console was not in UTF-8 mode to start with, then looked up in the
260   table describing the correspondence between Unicode values and font
261   positions, and the obtained 8- or 9-bit font indices are then written
262   to video memory, where they cause the display of character shapes
263   found in the video card's character ROM.  One can load one's own fonts
264   into character ROM using setfont, load the corresponding Unicode map
265   with loadunimap, and load a user mapping table using mapscrn.  More
266   details will be given below.
267
268   There are many consoles (called _\bV_\bi_\br_\bt_\bu_\ba_\bl _\bC_\bo_\bn_\bs_\bo_\bl_\be_\bs or _\bV_\bi_\br_\bt_\bu_\ba_\bl _\bT_\be_\br_\bm_\bi_\bn_\ba_\bl_\bs,
269   abbreviated VCs or VTs) that share the same screen. You can use them
270   as independent devices, either to run indendent login sessions, or
271   just to send some output to, perhaps from top, or the tail of the
272   system log or so.  See below (`Console switching') on how to set them
273   up and switch between them.
274
275
276
277   4\b4.\b.  R\bRe\bes\bse\bet\btt\bti\bin\bng\bg y\byo\bou\bur\br t\bte\ber\brm\bmi\bin\bna\bal\bl
278
279
280   There is garbage on the screen, or all your keystrokes are echoed as
281   line drawing characters. What to do?
282
283   Many programs will redraw the screen when Ctrl-L is typed. This might
284   help when there is some modem noise or broadcast message on your
285   screen.  The command clear will clear the screen.
286
287   The command reset will reset the console driver. This helps when the
288   screen is full of funny graphic characters, and also if it is reduced
289   to the bottom line. If you don't have this command, or if it does
290   something else, make your own by putting the following two lines in an
291   executable file reset in your PATH:
292
293
294                #!/bin/sh
295                echo -e \\033c
296
297
298
299
300   that is, you want to send the two characters ESC c to the console.
301
302   Why is it that the display sometimes gets confused and gives you a
303   24-line or 1-line screen, instead of the usual 25 lines?  Well, the
304   main culprit is the use of TERM=vt100 (or some other entry with 24
305   lines) instead of TERM=linux when logged in remotely.  If this happens
306   on /dev/tty2 then typing
307
308
309                % cat > /dev/tty2
310                ^[c
311                ^D
312
313
314
315
316   on some other VT (where 4 symbols are typed to cat: ESC, c, ENTER,
317   Ctrl-D) and refreshing the screen on /dev/tty2 (perhaps using Ctrl-L)
318   will fix things. Of course the permanent fix is to use the right term-
319   cap or terminfo entry.
320
321   Why is it that you sometimes get a lot of line-drawing characters,
322   e.g., after catting a binary to the screen?  Well, there are various
323   character set changing escape sequences, and by accident your binary
324   might contain some of these.  The ESC c is a general reset, a cure for
325   all, but if you know precisely what went wrong you can repair it
326   without resetting other console attributes. For example, after
327
328
329
330
331           % cat
332           ^N
333           ^D
334
335
336
337
338   your shell prompt will be all line-drawing characters.  Now do (typing
339   blindly)
340
341
342                % cat
343                ^O
344                ^D
345
346
347
348
349   and all is well again. (Three symbols typed to each cat: Ctrl-N (or
350   Ctrl-O), ENTER, Ctrl-D.) To understand what is happening, see `The
351   console character sets' below.
352
353   If you loaded some strange font, and want to return to the default,
354
355
356                % setfont
357
358
359
360
361   will do (provided you stored the default font in the default place).
362   If this default font does not contain an embedded Unicode map (and
363   gives the wrong symbols for accented characters), then say
364
365
366                % loadunimap
367
368
369
370
371   For example, if I do
372
373
374                % loadkeys de-latin1
375
376
377
378
379   then I have a German keyboard, and the key left of the Enter key gives
380   me a-umlaut. This works, because the a-umlaut occurs on the CP437 code
381   page and the kernel Unicode map is initialized to CP437, and my video
382   card has a CP437 font built-in.  If I now load an ISO 8859-1 font with
383
384
385                % setfont iso01.f16
386
387
388
389
390   then everything still works, because setfont invalidates the kernel
391   Unicode map (if there is no Unicode map attached to the font), and
392   without map the kernel goes directly to the font, and that is pre-
393   cisely correct for an ISO 8859-1 system with iso01.f16 font.  But
394   going back to the previous font with
395
396
397           % setfont
398
399
400
401
402   gives capital Sigma's instead of a-umlaut - all accented letters are
403   mixed up because also this font has no embedded Unicode map. After
404
405
406                % loadunimap
407
408
409
410
411   which loads the default Unicode map (which is right for the default
412   font) all works correctly again. Usually loadunimap is not invoked
413   directly, but via setfont. Thus, the previous two commands may be
414   replaced by
415
416
417                % setfont -u def
418
419
420
421
422   The Ethiopian fonts and the lat1u*.psf fonts have embedded Unicode
423   code map. Most of the others don't.
424
425   On old terminals output involving tabs may require a delay, and you
426   have to say
427
428
429                % stty tab3
430
431
432
433
434   (see stty(1)).
435
436   You can change the video mode using resizecons or SVGATextMode.  This
437   usually settles the output side.  On the input side there are many
438   things that might be wrong. If X or DOOM or some other program using
439   raw mode crashed, your keyboard may still be in raw (or mediumraw)
440   mode, and it is difficult to give commands.  (See "How to get out of
441   raw mode" below.)  If you loaded a bad keymap, then
442
443
444                % loadkeys -d
445
446
447
448
449   loads the default map again, but it may well be difficult to type `-'!
450   An alternative is
451
452
453                % loadkeys defkeymap
454
455
456
457
458   Sometimes even the letters are garbled. It is useful to know that
459   there are four main types of keyboards: QWERTY, QWERTZ, AZERTY and
460   DVORAK.  The first three are named after the first six letter keys,
461   and roughly represent the English, German and French speaking coun-
462   tries.  Compared to QWERTY, the QWERTZ map interchanges Y and Z.
463   Compared to QWERTY, the AZERTY map interchanges Q and A, W and Z, and
464   has its M right of the L, at the semicolon position.  DVORAK has an
465   entirely different letter ordering.  There are two types of Turkish
466   keyboard. The so-called `Q'-keyboard has a QWERTY layout, while the
467   `F'-keyboard has an entirely different layout, let us say fgGIod,
468   where G stands for Gbreve and I for dotlessi.
469
470
471   4\b4.\b.1\b1.\b.  K\bKe\bey\byb\bbo\boa\bar\brd\bd h\bha\bar\brd\bdw\bwa\bar\bre\be r\bre\bes\bse\bet\bt
472
473
474   Things may be wrong on a lower level than Linux knows about.  There
475   are at least two distinct lower levels (keyboard and keyboard
476   controller) where one can give the command "keyboard disable" to the
477   keyboard hardware.  Keyboards can often be programmed to use one out
478   of three different sets of scancodes.
479
480   However, I do not know of cases where this turned out to be a problem.
481
482   Some keyboards have a remapping capability built in.  Stormy Henderson
483   (stormy@Ghost.Net) writes: `If it's your keyboard accidently being
484   reprogrammed, you can (on a Gateway AnyKey keyboard) press control-
485   alt-suspend_macro to reset the keys to normal.'
486
487
488   5\b5.\b.  D\bDe\bel\ble\bet\bte\be a\ban\bnd\bd B\bBa\bac\bck\bks\bsp\bpa\bac\bce\be
489
490
491   Getting Delete and Backspace to work just right is nontrivial,
492   especially in a mixed environment, where you talk to console, to X, to
493   bash, to emacs, login remotely, etc.  You may have to edit several
494   configuration files to tell all of the programs involved precisely
495   what you want.  On the one hand, there is the matter of which keys
496   generate which codes (and how these codes are remapped by e.g. kermit
497   or emacs), and on the other hand the question of what functions are
498   bound to what codes.
499
500   People often complain `my backspace key does not work', as if this key
501   had a built-in function `delete previous character'.  Unfortunately,
502   all this key, or any key, does is producing a code, and one only can
503   hope that the kernel tty driver and all application programs can be
504   configured such that the backspace key indeed does function as a
505   `delete previous character' key.
506
507   Most Unix programs get their tty input via the kernel tty driver in
508   `cooked' mode, and a simple stty command determines the erase
509   character. However, programs like bash and emacs and X do their own
510   input handling, and have to be convinced one-by-one to do the right
511   thing.
512
513
514   5\b5.\b.1\b1.\b.  H\bHo\bow\bw t\bto\bo t\bte\bel\bll\bl U\bUn\bni\bix\bx w\bwh\bha\bat\bt c\bch\bha\bar\bra\bac\bct\bte\ber\br y\byo\bou\bu w\bwa\ban\bnt\bt t\bto\bo u\bus\bse\be t\bto\bo d\bde\bel\ble\bet\bte\be t\bth\bhe\be
515   l\bla\bas\bst\bt t\bty\byp\bpe\bed\bd c\bch\bha\bar\bra\bac\bct\bte\ber\br
516
517
518
519
520                % stty erase ^?
521
522
523
524
525   If the character is erased, but in a funny way, then something is
526   wrong with your tty settings. If echoprt is set, then erased charac-
527   ters are enclosed between \ and /.  If echoe is not set, then the
528   erase char is echoed (which is reasonable when it is a printing
529   character, like #).  Most people will want stty echoe -echoprt. Saying
530   stty sane will do this and more. Saying stty -a shows your current
531   settings.  How come this is not right by default? It is, if you use
532   the right getty.
533
534   Note that many programs (like bash, emacs etc.) have their own
535   keybindings (defined in ~/.inputrc, ~/.emacs etc.) and are unaffected
536   by the setting of the erase character.
537
538   The standard Unix tty driver does not recognize a cursor, or keys
539   (like the arrow keys) to move the current position, and hence does not
540   have a command `delete current character' either. But for example you
541   can get bash on the console to recognize the Delete key by putting
542
543
544                set editing-mode emacs
545                "\e[3~":delete-char
546
547
548
549
550   into ~/.inputrc.
551
552
553   5\b5.\b.1\b1.\b.1\b1.\b.  `\b`G\bGe\bet\btt\bty\by u\bus\bse\bed\bd t\bto\bo d\bdo\bo t\bth\bhe\be r\bri\big\bgh\bht\bt t\bth\bhi\bin\bng\bg w\bwi\bit\bth\bh D\bDE\bEL\bL a\ban\bnd\bd B\bBS\bS b\bbu\but\bt i\bis\bs b\bbr\bro\bo-\b-
554   k\bke\ben\bn n\bno\bow\bw?\b?'\b'
555
556
557   Earlier, the console driver would do BS Space BS (\010\040\010) when
558   it got a DEL (\177).  Nowadays, DEL's are ignored (as they should be,
559   since the driver emulates a vt100). Get a better getty, i.e., one that
560   does not output DEL.
561
562
563   5\b5.\b.1\b1.\b.2\b2.\b.  `\b`L\bLo\bog\bgi\bin\bn b\bbe\beh\bha\bav\bve\bes\bs d\bdi\bif\bff\bfe\ber\bre\ben\bnt\btl\bly\by a\bat\bt t\bth\bhe\be f\bfi\bir\brs\bst\bt a\ban\bnd\bd s\bse\bec\bco\bon\bnd\bd l\blo\bog\bgi\bin\bn
564   a\bat\btt\bte\bem\bmp\bpt\bts\bs?\b?'\b'
565
566
567   At the first attempt, you are talking to getty. At the second attempt,
568   you are talking to login, a different program.
569
570
571   5\b5.\b.2\b2.\b.  H\bHo\bow\bw t\bto\bo t\bte\bel\bll\bl L\bLi\bin\bnu\bux\bx w\bwh\bha\bat\bt c\bco\bod\bde\be t\bto\bo g\bge\ben\bne\ber\bra\bat\bte\be w\bwh\bhe\ben\bn a\ba k\bke\bey\by i\bis\bs p\bpr\bre\bes\bss\bse\bed\bd
572
573
574   On the console, or, more precisely, when not in (MEDIUM)RAW mode, use
575
576
577                % loadkeys mykeys.map
578
579
580
581
582   and under X use
583
584
585                % xmodmap mykeys.xmap
586
587
588
589
590   Note that (since XFree86-2.1) X reads the Linux settings of the
591   keymaps when initialising the X keymap. Although the two systems are
592   not 100% compatible, this should mean that in many cases the use of
593   xmodmap has become superfluous.
594
595   For example, suppose that you would like the Backspace key to send a
596   BackSpace (Ctrl-H, octal 010) and the grey Delete key a DEL (octal
597   0177). Add the following to /etc/rc.local (or wherever you keep your
598   local boot-time stuff):
599
600
601                /usr/bin/loadkeys << EOF
602                keycode 14 = BackSpace
603                keycode 111 = Delete
604                EOF
605
606
607
608
609   Note that this will only change the function of these keys when no
610   modifiers are used. (You need to specify a keymaps line to tell which
611   keymaps should be affected if you want to change bindings on more
612   keymaps.)  The Linux kernel default lets Ctrl-Backspace generate
613   BackSpace - this is sometimes useful as emergency escape, when you
614   find you can only generate DELs.
615
616   The left Alt key is sometimes called the Meta key, and by default the
617   combinations AltL-X are bound to the symbol MetaX.  But what character
618   sequence is MetaX?  That is determined (per-tty) by the Meta flag, set
619   by the command setmetamode. The two choices are: ESC X or X or-ed with
620   0200.
621
622   Many distributions have a loadkeys command somewhere in the bootup
623   sequence. For example, one may have the name of the desired keymap in
624   /etc/sysconfig/keyboard and the loadkeys command that loads it in
625   /etc/rc.d/init.d/keytable.  Or one may have the actual default keymap
626   in /etc/default.keytab and the loadkeys command that loads it in
627   /etc/rc.d/boot.  Etc. Instead of adding a local modification to the
628   default, one can of course change the default by editing the default
629   keymap or changing the name of the keymap to be loaded at boot time.
630   Note that loadkeys itself has default keymap defkeymap.map located
631   somewhere under /usr/lib/kbd or /usr/share/kbd (just like all other
632   keymaps) and this may not yet be available in single user boot before
633   /usr has been mounted.
634
635
636   5\b5.\b.2\b2.\b.1\b1.\b.  `\b`H\bHo\bow\bw d\bdo\bo I\bI g\bge\bet\bt a\ba d\bdv\bvo\bor\bra\bak\bk k\bke\bey\byb\bbo\boa\bar\brd\bd?\b?'\b'
637
638   The command
639
640
641                % loadkeys dvorak
642
643
644
645
646   will give you a dvorak layout, probably by loading something like
647   /usr/lib/kbd/keymaps/i386/dvorak/dvorak.map.gz.  Under X, put
648
649
650                XkbLayout       "dvorak"
651
652
653
654
655   in XF86Config.
656
657
658
659
660
661   5\b5.\b.2\b2.\b.2\b2.\b.  `\b`W\bWh\bhy\by d\bdo\boe\bes\bsn\bn'\b't\bt t\bth\bhe\be B\bBa\bac\bck\bks\bsp\bpa\bac\bce\be k\bke\bey\by g\bge\ben\bne\ber\bra\bat\bte\be B\bBa\bac\bck\bkS\bSp\bpa\bac\bce\be b\bby\by d\bde\bef\bfa\bau\bul\blt\bt?\b?'\b'
662
663
664   (i) Because the VT100 had a Delete key above the Enter key.
665
666   (ii) Because Linus decided so.
667
668
669   5\b5.\b.3\b3.\b.  H\bHo\bow\bw t\bto\bo t\bte\bel\bll\bl X\bX t\bto\bo i\bin\bnt\bte\ber\brc\bch\bha\ban\bng\bge\be D\bDe\bel\ble\bet\bte\be a\ban\bnd\bd B\bBa\bac\bck\bks\bsp\bpa\bac\bce\be
670
671
672
673
674                % xmodmap -e "keysym BackSpace = Delete" -e "keysym Delete = BackSpace"
675
676
677
678
679   Or, if you just want the Backspace key to generate a BackSpace:
680
681
682                % xmodmap -e "keycode 22 = BackSpace"
683
684
685
686
687   Or, if you just want the Delete key to generate a Delete:
688
689
690                % xmodmap -e "keycode 107 = Delete"
691
692
693
694
695   (but usually this is the default binding already).
696
697
698   5\b5.\b.4\b4.\b.  H\bHo\bow\bw t\bto\bo t\bte\bel\bll\bl e\bem\bma\bac\bcs\bs w\bwh\bha\bat\bt t\bto\bo d\bdo\bo w\bwh\bhe\ben\bn i\bit\bt r\bre\bec\bce\bei\biv\bve\bes\bs a\ba D\bDe\bel\ble\bet\bte\be o\bor\br
699   B\bBa\bac\bck\bks\bsp\bpa\bac\bce\be
700
701
702   Put in your .emacs file lines like
703
704
705                (global-set-key "\?" 'help-command)
706                (global-set-key "\C-h" 'delete-backward-char)
707
708
709
710
711   Of course you can bind other commands to other keys in the same way.
712   Note that various major and minor modes redefine keybindings.  For
713   example, in incremental search mode one finds the code
714
715
716                (define-key map "\177" 'isearch-delete-char)
717                (define-key map "\C-h" 'isearch-mode-help)
718
719
720
721
722   This means that it may be a bad idea to use the above two global-set-
723   key commands. There are too many places where there are built-in
724   assumptions about Ctrl-H = help and DEL = delete.  That doesn't mean
725   that you have to setup keys so that Backspace generates DEL. But if it
726   doesn't then it is easiest to remap them at the lowest possible level
727   in emacs.
728
729
730   5\b5.\b.5\b5.\b.  H\bHo\bow\bw t\bto\bo t\bte\bel\bll\bl e\bem\bma\bac\bcs\bs t\bto\bo i\bin\bnt\bte\ber\brc\bch\bha\ban\bng\bge\be D\bDe\bel\ble\bet\bte\be a\ban\bnd\bd B\bBa\bac\bck\bks\bsp\bpa\bac\bce\be
731
732
733   Put in your .emacs file lines
734
735
736                (setq keyboard-translate-table (make-string 128 0))
737                (let ((i 0))
738                  (while (< i 128)
739                    (aset keyboard-translate-table i i)
740                    (setq i (1+ i))))
741                (aset keyboard-translate-table ?\b ?\^?)
742                (aset keyboard-translate-table ?\^? ?\b)
743
744
745
746
747   Recent versions of emacs have a function keyboard-translate and one
748   may simplify the above to
749
750
751                (keyboard-translate ?\C-h ?\C-?)
752                (keyboard-translate ?\C-? ?\C-h)
753
754
755
756
757   Note that under X emacs can distinguish between Ctrl-h and the
758   Backspace key (regardless of what codes these produce on the console),
759   and by default emacs will view the Backspace key as DEL (and do dele-
760   tion things, as bound to that character, rather than help things,
761   bound to Ctrl-H). One can distinguish Backspace and Delete, e.g. by
762
763
764                (global-unset-key [backspace] )
765                (global-set-key [backspace] 'delete-backward-char)
766                (global-unset-key [delete] )
767                (global-set-key [delete] 'delete-char)
768
769
770
771
772
773   5\b5.\b.6\b6.\b.  H\bHo\bow\bw t\bto\bo t\bte\bel\bll\bl k\bke\ber\brm\bmi\bit\bt t\bto\bo i\bin\bnt\bte\ber\brc\bch\bha\ban\bng\bge\be D\bDe\bel\ble\bet\bte\be a\ban\bnd\bd B\bBa\bac\bck\bks\bsp\bpa\bac\bce\be
774
775
776   Put in your .kermrc file the lines
777
778
779                set key \127 \8
780                set key \8 \127
781
782
783
784
785
786   5\b5.\b.7\b7.\b.  H\bHo\bow\bw t\bto\bo t\bte\bel\bll\bl x\bxt\bte\ber\brm\bm t\bto\bo i\bin\bnt\bte\ber\brc\bch\bha\ban\bng\bge\be D\bDe\bel\ble\bet\bte\be a\ban\bnd\bd B\bBa\bac\bck\bks\bsp\bpa\bac\bce\be
787
788
789
790
791
792
793   XTerm*VT100.Translations:       #override\n\
794           <KeyPress> BackSpace : string(0x7f)\n\
795           <KeyPress> Delete : string(0x08)\n
796
797
798
799
800
801   5\b5.\b.8\b8.\b.  H\bHo\bow\bw t\bto\bo t\bte\bel\bll\bl x\bxt\bte\ber\brm\bm a\bab\bbo\bou\but\bt y\byo\bou\bur\br f\bfa\bav\bvo\bou\bur\bri\bit\bte\be t\btt\bty\by m\bmo\bod\bde\bes\bs
802
803
804   Normally xterm will inherit the tty modes from its invoker.  Under
805   xdm, the default erase and kill characters are # and @, as in good old
806   Unix Version 6.  If you don't like that, you might put something like
807
808
809                XTerm*ttymodes: erase ^? kill ^U intr ^C quit ^\ eof ^D \
810                                susp ^Z start ^Q stop ^S eol ^@
811
812
813
814
815   in /usr/lib/X11/app-defaults/XTerm or in $HOME/.Xresources, assuming
816   that you have a line
817
818
819                xrdb -merge $HOME/.Xresources
820
821
822
823
824   in your $HOME/.xinitrc or $HOME/.xsession.
825
826
827   5\b5.\b.9\b9.\b.  H\bHo\bow\bw t\bto\bo t\bte\bel\bll\bl x\bxm\bmo\bos\bsa\bai\bic\bc t\bth\bha\bat\bt t\bth\bhe\be B\bBa\bac\bck\bks\bsp\bpa\bac\bce\be k\bke\bey\by g\bge\ben\bne\ber\bra\bat\bte\bes\bs a\ba D\bDE\bEL\bL
828
829
830   Putting
831
832
833                *XmText.translations: #override\n\
834                   <Key>osfDelete: delete-previous-character()
835                *XmTextField.translations: #override\n\
836                   <Key>osfDelete: delete-previous-character()
837
838
839
840
841   in your $HOME/.Xdefaults or $HOME/.Xresources helps.  (What file? The
842   file that is fed to xrdb, for example in .xinitrc.)
843
844   The netscape FAQ, however, says:
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859           Why doesn't my Backspace key work in text fields?
860           By default, Linux and XFree86 come with the Backspace and Delete keys
861           misconfigured. All Motif programs (including, of course, Netscape
862           Navigator) will malfunction in the same way.
863
864           The Motif spec says that Backspace is supposed to delete the previous
865           character and Delete is supposed to delete the following character.
866           Linux and XFree86 come configured with both the Backspace and Delete
867           keys generating Delete.
868
869           You can fix this by using any one of the xmodmap, xkeycaps, or
870           loadkeys programs to make the key in question generate the BackSpace
871           keysym instead of Delete.
872
873           You can also fix it by having a .motifbind file; see the man page
874           for VirtualBindings(3).
875
876           Note: Don't use the *XmText.translations or *XmTextField.translations
877           resources to attempt to fix this problem. If you do, you will blow
878           away Netscape Navigator's other text-field key bindings.
879
880
881
882
883   5\b5.\b.1\b10\b0.\b.  A\bA b\bbe\bet\btt\bte\ber\br s\bso\bol\blu\but\bti\bio\bon\bn f\bfo\bor\br M\bMo\bot\bti\bif\bf-\b-u\bus\bsi\bin\bng\bg p\bpr\bro\bog\bgr\bra\bam\bms\bs,\b, l\bli\bik\bke\be n\bne\bet\bts\bsc\bca\bap\bpe\be
884
885
886   Ted Kandell (ted@tcg.net) suggests the following:
887
888   Somewhere in your .profile add the following:
889
890
891        stty erase ^H
892
893
894
895
896   If you are using bash, add the following lines to your .inputrc:
897
898
899        "\C-?": delete-char
900        "\C-h": backward-delete-char
901
902
903
904
905   Add the following lines to your .xinitrc file:
906
907
908        xmodmap <<-EOF
909        keycode 22  =  BackSpace osfBackSpace
910        keycode 107 =  Delete
911        EOF
912
913        # start your window manager here,  for example:
914        #(fvwm) 2>&1 | tee /dev/tty /dev/console
915
916        stty sane
917        stty erase ^H
918        loadmap <<-EOF
919        keycode 14  = BackSpace
920        keycode 111 = Delete
921        EOF
922
923
924
925   This will definitely work for a PC 101 or 102 key keyboard with any
926   Linux/XFree86 layout.
927
928   The important part to making Motif apps like Netscape work properly is
929   adding osfBackSpace to keycode 22 in addition to BackSpace.
930
931   Note that there must be spaces on either side of the = sign.
932
933
934
935   5\b5.\b.1\b11\b1.\b.  W\bWh\bha\bat\bt a\bab\bbo\bou\but\bt t\bte\ber\brm\bmc\bca\bap\bp a\ban\bnd\bd t\bte\ber\brm\bmi\bin\bnf\bfo\bo?\b?
936
937
938   When people have problems with backspace, they tend to look at their
939   termcap (or terminfo) entry for the terminal, and indeed, there does
940   exist a kb (or kbs) capability describing the code generated by the
941   Backspace key.  However, not many programs use it, so unless you are
942   having problems with one particular program only, probably the fault
943   is elsewhere.  Of course it is a good idea anyway to correct your
944   termcap (terminfo) entry.  See also below under "The TERM variable".
945
946
947   5\b5.\b.1\b12\b2.\b.  A\bA c\bco\bom\bmp\bpl\ble\bet\bte\be s\bso\bol\blu\but\bti\bio\bon\bn
948
949   There are many possibilities to get a functioning system.  Can't you
950   give one complete set of settings that works?
951
952   One way of getting a setup that works in all contexts is to have the
953   Backspace key generate DEL when on the console (or xterm), and
954   BackSpace when under X.  Maybe that is most convenient - there are too
955   many X utilities that expect BackSpace, and emacs on the console or
956   xterm expects DEL, while emacs under X can distinguish [BackSpace]
957   from Ctrl-H and does the right thing.
958
959   What is needed?  No loadkeys changes, since the Backspace key already
960   generates DEL by default.  No stty settings, they are OK by default.
961   No X settings, they are OK by default.  One just has to tell xterm
962   that the Backspace key should generate DEL: put
963
964
965        XTerm*VT100.Translations:       #override\n\
966                <KeyPress> BackSpace : string(0x7f)\n\
967
968
969
970
971   in .Xresources, and
972
973
974        xrdb -merge .Xresources
975
976
977
978
979   in .xinitrc, and you are settled.
980
981   For a much more extensive discussion of these things, and alternative
982   solutions, see Anne Baretta's page.
983
984
985   6\b6.\b.  T\bTh\bhe\be c\bco\bon\bns\bso\bol\ble\be c\bch\bha\bar\bra\bac\bct\bte\ber\br s\bse\bet\bts\bs
986
987
988   The kernel first tries to figure out what symbol is meant by any given
989   user byte, and next where this symbol is located in the current font.
990
991   The kernel knows about 5 translations of bytes into console-screen
992   symbols.  In Unicode (UTF-8) mode, the UTF-8 code is just converted
993   directly into Unicode. The assumption is that almost all symbols one
994   needs are present in Unicode, and for the cases where this does not
995   hold the codes 0xff** are reserved for direct font access.  When not
996   in Unicode mode, one of four translation tables is used.  The four
997   tables are: a) Latin1 -> Unicode,  b) VT100 graphics -> Unicode, c) PC
998   -> Unicode, d) user-defined.
999
1000   There are two character sets, called G0 and G1, and one of them is the
1001   current character set. (Initially G0.)  Typing Ctrl-N causes G1 to
1002   become current, Ctrl-O causes G0 to become current.
1003
1004   These variables G0 and G1 point at a translation table, and can be
1005   changed by the user. Initially they point at tables a) and b),
1006   respectively.  The sequences ESC ( B and ESC ( 0 and ESC ( U and ESC (
1007   K cause G0 to point at translation table a), b), c) and d),
1008   respectively.  The sequences ESC ) B and ESC ) 0 and ESC ) U and ESC )
1009   K cause G1 to point at translation table a), b), c) and d),
1010   respectively.
1011
1012   The sequence ESC c causes a terminal reset, which is what you want if
1013   the screen is all garbled. The oft-advised echo ^V^O will only make G0
1014   current, but there is no guarantee that G0 points at table a).  In
1015   some distributions there is a program reset(1) that just does echo
1016   ^[c.  If your termcap entry for the console is correct (and has an
1017   entry :rs=\Ec:), then also setterm -reset will work.
1018
1019   The user-defined mapping table can be set using mapscrn(8).  The
1020   result of the mapping is that if a symbol c is printed, the symbol s =
1021   map[c] is sent to the video memory. The bitmap that corresponds to s
1022   is found in the character ROM, and can be changed using setfont(8).
1023
1024
1025   7\b7.\b.  C\bCo\bon\bns\bso\bol\ble\be s\bsw\bwi\bit\btc\bch\bhi\bin\bng\bg
1026
1027
1028   By default, console switching is done using Alt-Fn or Ctrl-Alt-Fn.
1029   Under X (or recent versions of dosemu), only Ctrl-Alt-Fn works.  Many
1030   keymaps will allow cyclic walks through all allocated consoles using
1031   Alt-RightArrow and Alt-LeftArrow.
1032
1033   XFree86 1.3 does not know that Alt is down when you switch to the X
1034   window. Thus, you cannot switch immediately to some other VT again but
1035   have to release Alt first.  In the other direction this should work:
1036   the kernel always keeps track of the up/down status of all keys. (As
1037   far as possible: on some keyboards some keys do not emit a scancode
1038   when pressed (e.g.: the PFn keys of a FOCUS 9000) or released (e.g.:
1039   the Pause key of many keyboards).)
1040
1041   XFree86 1.3 saves the fonts loaded in the character ROMs when started,
1042   and restores it on a console switch. Thus, the result of setfont on a
1043   VT is wiped out when you go to X and back.  Using setfont under X will
1044   lead to funny results.
1045
1046   One can change VT under program control using the chvt command.
1047
1048
1049   7\b7.\b.1\b1.\b.  C\bCh\bha\ban\bng\bgi\bin\bng\bg t\bth\bhe\be n\bnu\bum\bmb\bbe\ber\br o\bof\bf V\bVi\bir\brt\btu\bua\bal\bl C\bCo\bon\bns\bso\bol\ble\bes\bs
1050
1051
1052   This question still comes up from time to time, but the answer is: you
1053   already have enough of them.  Since kernel version 1.1.54, there are
1054   between 1 and 63 virtual consoles. A new one is created as soon as it
1055   is opened. It is removed by the utility deallocvt (but it can be
1056   removed only when no processes are associated to it anymore, and no
1057   text on it has been selected by programs like selection or gpm).
1058
1059   For older kernels, change the line
1060
1061
1062                #define NR_CONSOLES     8
1063
1064
1065
1066
1067   in include/linux/tty.h (don't increase this number beyond 63), and
1068   recompile the kernel.
1069
1070   If they do not exist yet, create the tty devices with MAKEDEV or mknod
1071   ttyN c 4 N where N denotes the tty number. For example,
1072
1073
1074                for i in 9 10 11 12; do mknod /dev/tty$i c 4 $i; done
1075
1076
1077
1078
1079   or, better (since it also takes care of owner and permissions),
1080
1081
1082                for i in 9 10 11 12; do /dev/MAKEDEV tty$i; done
1083
1084
1085
1086
1087   If you want the new VCs to run getty, add lines in /etc/inittab.  (But
1088   it is much better to have only two getty's running, and to create more
1089   consoles dynamically as the need arises.  That way you'll have more
1090   memory when you don't use all these consoles, and also more consoles,
1091   in case you really need them.  Edit /etc/inittab and comment out all
1092   getty's except for the first two.)
1093
1094   When the consoles are allocated dynamically, it is usually easiest to
1095   have only one or two running getty. More are opened by open -l -s
1096   bash. Unused consoles (without associated processes) are deallocated
1097   using deallocvt (formerly disalloc).  But, you say, I am involved in
1098   activities when I suddenly need more consoles, and do not have a bash
1099   prompt available to give the open command.  Fortunately it is possible
1100   to create a new console upon a single keystroke, regardless of what is
1101   happening at the current console.
1102
1103   If you have spawn_login from kbd-0.99.tar.gz and you put
1104
1105
1106                loadkeys << EOF
1107                alt keycode 103 = Spawn_Console
1108                EOF
1109                spawn_login &
1110
1111
1112
1113
1114   in /etc/rc.local, then typing Alt-UpArrow will create a fresh VC run-
1115   ning login (and switch to it). With spawn_console & instead of
1116   spawn_login & you'll have bash running there.  See also open-1.4.tgz
1117   and dynamic-vc-1.1.tar.gz.
1118
1119   What action should be taken upon this Spawn_Console keypress can also
1120   be set in /etc/inittab under kbrequest, if you have a recent init. See
1121   inittab(5).
1122
1123   (This action can be something entirely different - I just called the
1124   key Spawn_Console because that is what I used it for.  When used for
1125   other purposes it is less confusing to use its synonym KeyboardSignal.
1126   For example, some people like to put the lines
1127
1128
1129                kb::kbrequest:/sbin/shutdown -h now
1130
1131
1132
1133
1134   in /etc/inittab, and
1135
1136
1137                control alt keycode 79 = KeyboardSignal
1138                control alt keycode 107 = KeyboardSignal
1139
1140
1141
1142
1143   in their keymap. Now Ctrl-Alt-End will do a system shutdown.)
1144
1145   You can only login as "root" on terminals listed in /etc/securetty.
1146   There exist programs that read terminal settings from files /etc/ttys
1147   and /etc/ttytype. If you have such files, and create additional
1148   consoles, then it might be a good idea to also add entries for them in
1149   these files.
1150
1151
1152   8\b8.\b.  C\bCt\btr\brl\bl-\b-A\bAl\blt\bt-\b-D\bDe\bel\bl a\ban\bnd\bd o\bot\bth\bhe\ber\br s\bsp\bpe\bec\bci\bia\bal\bl k\bke\bey\by c\bco\bom\bmb\bbi\bin\bna\bat\bti\bio\bon\bns\bs
1153
1154
1155
1156   8\b8.\b.1\b1.\b.  C\bCt\btr\brl\bl-\b-A\bAl\blt\bt-\b-D\bDe\bel\bl (\b(B\bBo\boo\bot\bt)\b)
1157
1158
1159   If you press Ctrl-Alt-Del (or whatever key was assigned the keysym
1160   Boot by loadkeys) then either the machine reboots immediately (without
1161   sync), or init is sent a SIGINT. The former behaviour is the default.
1162   The default can be changed by root, using the system call reboot(),
1163   see ctrlaltdel(8).  Some init's change the default. What happens when
1164   init gets SIGINT depends on the version of init used - often it will
1165   be determined by the pf entry in /etc/inittab (which means that you
1166   can run an arbitrary program in this case).  In the current kernel
1167   Ctrl-AltGr-Del is no longer by default assigned to Boot.
1168
1169
1170   8\b8.\b.2\b2.\b.  O\bOt\bth\bhe\ber\br c\bco\bom\bmb\bbi\bin\bna\bat\bti\bio\bon\bns\bs
1171
1172
1173
1174   Name            Default binding
1175   -------------------------------
1176   Show_Memory     Shift-Scrollock
1177   Show_Registers  AltGr-ScrollLock
1178   Show_State      Ctrl-ScrollLock
1179   Console_n       Alt-Fn and Ctrl-Alt-Fn  (1 <= n <= 12)
1180   Console_{n+12}  AltGr-Fn                (1 <= n <= 12)
1181   Incr_Console    Alt-RightArrow
1182   Decr_Console    Alt-LeftArrow
1183   Last_Console    Alt[Gr]-PrintScreen
1184   Scroll_Backward Shift-PageUp
1185   Scroll_Forward  Shift-PageDown
1186   Caps_On                                 (CapsLock is a toggle; this key sets)
1187   Compose         Ctrl-.
1188
1189   8\b8.\b.3\b3.\b.  X\bX C\bCo\bom\bmb\bbi\bin\bna\bat\bti\bio\bon\bns\bs
1190
1191
1192
1193   Ctrl-Alt-Fn     Switch to VT n
1194   Ctrl-Alt-KP+    Next mode
1195   Ctrl-Alt-KP-    Previous mode
1196   Ctrl-Alt-Backspace      Kill X
1197
1198
1199   On some motherboards, Ctrl-Alt-KP- and Ctrl-Alt-KP+ will be equivalent
1200   to pressing the Turbo button. That is, both will produce the scancodes
1201   1d 38 4a ca b8 9d and 1d 38 4e ce b8 9d, and both will switch between
1202   Turbo (>= 25MHz) and non-Turbo (8 or 12 MHz).  (Often these key combi-
1203   nations only function this way when enabled by jumpers on the mother-
1204   board.)
1205
1206   Perry F Nguyen (pfnguyen@netcom22.netcom.com) writes: AMI BIOS has a
1207   feature that locks up the keyboard and flashes the LED's if the Ctrl-
1208   Alt-Backspace combination is pressed while a BIOS password is enabled,
1209   until the CMOS/BIOS password is typed in.
1210
1211
1212   8\b8.\b.4\b4.\b.  D\bDo\bos\bse\bem\bmu\bu C\bCo\bom\bmb\bbi\bin\bna\bat\bti\bio\bon\bns\bs
1213
1214
1215
1216   Ctrl-Alt-Fn     Switch to VT n (from version 0.50; earlier Alt-Fn)
1217   Ctrl-Alt-PgDn   Kill dosemu (when in RAW keyboard mode)
1218   (and many other combinations - see the dosemu documentation)
1219
1220
1221
1222
1223   8\b8.\b.5\b5.\b.  C\bCo\bom\bmp\bpo\bos\bsi\bin\bng\bg s\bsy\bym\bmb\bbo\bol\bls\bs
1224
1225
1226   One symbol may be constructed using several keystrokes.
1227
1228   +\bo  LeftAlt-press, followed by a decimal number typed on the keypad,
1229      followed by LeftAlt-release, yields the symbol with code given by
1230      this number.  (In Unicode mode this same mechanism, but then with 4
1231      hexadecimal digits, may be used to define a Unicode symbol.)
1232
1233   +\bo  A dead diacritic followed by a symbol, yields that symbol adorned
1234      with that diacritic. If the combination is undefined, both keys are
1235      taken separately.  Which keys are dead diacritics is user-settable;
1236      none is by default.  Five (since 2.0.25 six) dead diacritics can be
1237      defined (using loadkeys(1)): dead_grave, dead_acute,
1238      dead_circumflex, dead_tilde, dead_diaeresis (and dead_cedilla).
1239      Precisely what this adorning means is also user-settable: dead-
1240      diacritic, symbol is equivalent to Compose + diacritic + symbol.
1241
1242   +\bo  Compose followed by two symbols yields a combination symbol. These
1243      combinations are user-settable. Today there are 68 combinations
1244      defined by default; you can see them by saying "dumpkeys | grep
1245      compose".
1246
1247   +\bo  Then there are `Sticky' modifier keys (since 1.3.33). For example,
1248      one can type Ctrl-C as SControl, C and Ctrl-Alt-BackSpace as
1249      SControl, SAlt, BackSpace.
1250
1251   Note that there are at least four such composition mechanisms:
1252
1253   1. The Linux keyboard driver mechanism, used in conjunction with
1254      loadkeys.
1255   2. The X mechanism - see X386keybd(1), later XFree86kbd(1).  Under
1256      X11R6: edit /usr/X11R6/lib/X11/locale/iso8859-1/Compose.
1257
1258      See also Andrew D. Balsa's comments at
1259      http://wauug.erols.com/~balsa/linux/deadkeys/index.html.
1260
1261   3. The emacs mechanism obtained by loading "iso-insert.el" or calling
1262      `iso-accents-mode'.
1263
1264   4. The vim mechanism: insert a composed symbol by pressing Ctrl-K
1265      followed by two symbols. A list of the possible combinations is
1266      obtained by the command :digraphs.
1267
1268      For X the order of the two symbols is arbitrary: both Compose-,-c
1269      and Compose-c-, yield a c-cedilla; for Linux and emacs only the
1270      former sequence works by default. For X and vim the list of compose
1271      combinations is fixed.  Linux and emacs are flexible.  The default
1272      lists are somewhat similar, but the details are different.
1273
1274
1275   8\b8.\b.6\b6.\b.  T\bTh\bhe\be S\bSy\bys\bsR\bRq\bq k\bke\bey\by
1276
1277   In case your kernel was compiled with CONFIG_MAGIC_SYSRQ enabled (a
1278   feature that is present since Linux 2.1.43) there is a single key
1279   (defined in <linux/keyboard.h>) to which special system functions are
1280   attached, regardless of the current keyboard mode. For the PC
1281   architecture this special key is, naturally, the Alt+SysRq key, and
1282   any of the two Alt keys will work.  (Note that if CONFIG_MAGIC_SYSRQ
1283   was not enabled, the default action of this key is to return to the
1284   previous console.)
1285
1286   If you press this key, do not release it, and hit another key, a
1287   corresponding action is performed. The action is performed whether
1288   anybody is logged in or not, is root or not. For the details, see
1289   drivers/char/sysrq.c. Since this feature is meant only for kernel
1290   hackers, that should suffice. Still, let me add a few remarks.
1291
1292   For the key r the keyboard mode is reset to K_XLATE.  For the key k a
1293   SAK and console reset is done.  For the key b the machine is rebooted
1294   immediately.  (See, not something you want to have enabled on a
1295   production machine.)  For the key o the power is turned off (when the
1296   machine is capable of that).  For the key s an emergency sync is
1297   scheduled.  For the key u an emergency read-only remount is scheduled.
1298   For the keys p,t,m various information is shown (namely the same
1299   information also shown for RAlt,RCtrl,RShift+ScrollLock).  For the
1300   keys e,i,l all processes get a SIG_TERM or SIG_KILL, respectively; for
1301   l even the init process is killed.  Digits set the log level. Anything
1302   else prints a short summary: SysRq: unRaw saK Boot Off Sync Unmount
1303   showPc showTasks showMem loglevel0-8 tErm kIll killalL.
1304
1305   Note: These are very dangerous actions! And they do not use your
1306   keymap - indeed, are meant for emergency cases where the state of your
1307   keymap, or even of the entire kernel, is uncertain.  If you use a
1308   dvorak keyboard - bad luck! Most other people will be able to survive:
1309   the dangerous letters A,M,Q,W,Y,Z that are differently placed on
1310   English, French and German keyboards, are not used for actions. (But
1311   if your finger slips and you hit L instead of K - bye bye to your
1312   system.)
1313
1314
1315   9\b9.\b.  H\bHo\bow\bw t\bto\bo g\bge\bet\bt o\bou\but\bt o\bof\bf r\bra\baw\bw m\bmo\bod\bde\be
1316
1317
1318   If some program using K_RAW keyboard mode exits without restoring the
1319   keyboard mode to K_XLATE, then it is difficult to do anything - not
1320   even Ctrl-Alt-Del works. However, it is sometimes possible to avoid
1321   hitting the reset button.  (And desirable as well: your users may get
1322   angry if you kill their Hack game by rebooting; you might also damage
1323   your file system.)  Easy solutions involve logging in from another
1324   terminal or another machine and doing kbd_mode -a.  The procedure
1325   below assumes that no X is running, that the display is in text mode,
1326   and that you are at your bash prompt, that you are using a US keyboard
1327   layout, and that your interrupt character is Ctrl-C.
1328
1329   Step 1. Start X.  As follows: press 2 (and don't release), press F12
1330   (and don't release) and immediately afterwards press = . This starts
1331   X.  (Explanation: if a key press produces keycode K, then the key
1332   release produces keycode K+128. Probably your shell does not like
1333   these high characters, so we avoid generating them by not releasing
1334   any key.  However, we have to be quick, otherwise key repeat starts.
1335   The digit 2 produces a Ctrl-C that discards previous junk, the F12
1336   produces an X and the = a Return.)  Probably your screen will be grey
1337   now, since no .xinitrc was specified.  However, Ctrl-Alt-Fn will work
1338   and you can go to another VT.  (Ctrl-Alt-Backspace also works, but
1339   that exits X, and gets you back into the previous state, which is not
1340   what you want.)
1341
1342   Step 2. Setup to change the keyboard mode.  (For example, by sleep 5;
1343   kbd_mode -a.)
1344
1345   Step 3. Leave X again.  Alt-Fx (often Alt-F7) brings you back to X,
1346   and then Ctrl-Alt-Backspace exits X. Within 5 seconds your keyboard
1347   will be usable again.
1348
1349   If you want to prepare for the occasion, then make \215A\301 (3
1350   symbols) an alias for kbd_mode -a.  Now just hitting = F7 = (3
1351   symbols) will return you to sanity.
1352
1353
1354   1\b10\b0.\b.  T\bTh\bhe\be k\bke\bey\byb\bbo\boa\bar\brd\bd L\bLE\bED\bDs\bs
1355
1356
1357   1. There are per-tty keyboard flags: each VC has its own NumLock,
1358   CapsLock, ScrollLock.  By default these keyboard flags are shown in
1359   the LEDs.  The usual way to change them is by pressing the
1360   corresponding key.  (Side remark: pressing the NumLock key when in
1361   application key mode will not change the NumLock status, but produce
1362   an escape sequence.  If you want the NumLock key to always change the
1363   Numlock status, bind it to Bare_Num_Lock.)
1364
1365   2. Next, there are per-tty default keyboard flags, to initialize the
1366   keyboard flags when a reset occurs.  Thus if you want NumLock on all
1367   the time, that is possible.  The usual way to change them is by
1368   `setleds -D ...'.
1369
1370   3. There is the possibility that the leds do not reflect the keyboard
1371   flags, but something else.
1372
1373   3A. This something else can be three bits somewhere in the kernel -
1374   which can be used if you want to monitor some hardware or software
1375   status bit(s). If you want this, edit the kernel source to call
1376   register_leds() somewhere.
1377
1378   3B. This something else can also be whatever some user program wants
1379   to show in the LEDs. Thus, people who like such things can make nice
1380   patterns of lights. If you want this, use the KDSETLED ioctl.
1381
1382   This latter use is not per-tty, but the choice between former and
1383   latter use is per-tty.
1384
1385   Summarizing: Each tty has a flag kbd->ledmode.  If this has the value
1386   LED_SHOW_FLAGS then the keyboard flags (NumLock etc.) of that tty are
1387   shown.  If this has the value LED_SHOW_MEM then three selected memory
1388   addresses are shown.  If this has the value LED_SHOW_IOCTL then the
1389   leds show whatever value was last assigned to them using the KDSETLED
1390   ioctl.
1391
1392   One may add that X uses ioctl's to set the LEDs, but fails to reset
1393   its VT when it exits, so after using X there may be one VT that is not
1394   in the default LED_SHOW_FLAGS state.  This can be fixed by doing
1395   `setleds -L' on that VT.  See setleds(1).
1396
1397
1398   1\b11\b1.\b.  T\bTh\bhe\be T\bTE\bER\bRM\bM v\bva\bar\bri\bia\bab\bbl\ble\be
1399
1400
1401   Many programs use the TERM variable and the database /etc/termcap or
1402   /usr/lib/terminfo/* to decide which strings to send for clear screen,
1403   move cursor, etc., and sometimes also to decide which string is sent
1404   by the users backspace key, function keys etc.  This value is first
1405   set by the kernel (for the console).  Usually, this variable is re-set
1406   by getty, using /etc/ttytype or the argument specified in
1407   /etc/inittab.  Sometimes, it is also set in /etc/profile.
1408
1409   Older systems use TERM=console or TERM=con80x25. Newer systems (with
1410   ncurses 1.8.6) use the more specific TERM=linux or TERM=linux-80x25.
1411   However, old versions of setterm test for TERM=con* and hence fail to
1412   work with TERM=linux.
1413
1414   Since kernel version 1.3.2, the kernel default for the console is
1415   TERM=linux.
1416
1417   If you have a termcap without entry for linux, add the word linux to
1418   the entry for the console:
1419
1420
1421                console|con80x25|linux:\
1422
1423
1424
1425
1426   and make /usr/lib/terminfo/l/linux a copy of or symbolic link to
1427   /usr/lib/terminfo/c/console.
1428
1429
1430   1\b11\b1.\b.1\b1.\b.  T\bTe\ber\brm\bmi\bin\bnf\bfo\bo
1431
1432
1433   The terminfo entry for the linux console from ncurses 1.8.6 misses the
1434   entry kich1=\E[2~, needed by some programs.  Edit the file and tic it.
1435
1436
1437   1\b12\b2.\b.  H\bHo\bow\bw t\bto\bo m\bma\bak\bke\be o\bot\bth\bhe\ber\br p\bpr\bro\bog\bgr\bra\bam\bms\bs w\bwo\bor\brk\bk w\bwi\bit\bth\bh n\bno\bon\bn-\b-A\bAS\bSC\bCI\bII\bI c\bch\bha\bar\brs\bs
1438
1439
1440   In the bad old days this used to be quite a hassle. Every separate
1441   program had to be convinced individually to leave your bits alone.
1442   Not that all is easy now, but recently a lot of gnu utilities have
1443   learned to react to LC_CTYPE=iso_8859_1 or LC_CTYPE=iso-8859-1.  Try
1444   this first, and if it doesn't help look at the hints below.  Note that
1445   in recent versions of libc the routine setlocale() only works if you
1446   have installed the locale files (e.g. in /usr/lib/locale).
1447
1448   First of all, the 8-th bit should survive the kernel input processing,
1449   so make sure to have stty cs8 -istrip -parenb set.
1450
1451   A. For emacs the details strongly depend on the version.  The
1452   information below is for version 19.34. Put lines
1453                (set-input-mode nil nil 1)
1454                (standard-display-european t)
1455                (require 'iso-syntax)
1456
1457
1458
1459
1460   into your $HOME/.emacs.  The first line (to be precise: the final 1)
1461   tells emacs not to discard the 8-th bit from input characters.  The
1462   second line tells emacs not to display non-ASCII characters as octal
1463   escapes.  The third line specifies the syntactic properties and case
1464   conversion table for the Latin-1 character set These last two lines
1465   are superfluous if you have something like LC_CTYPE=ISO-8859-1 in your
1466   environment.  (The variable may also be LC_ALL or even LANG.  The
1467   value may be anything with a substring `88591' or `8859-1' or
1468   `8859_1'.)
1469
1470   This is a good start.  On a terminal that cannot display non-ASCII ISO
1471   8859-1 symbols, the command
1472
1473
1474                (load-library "iso-ascii")
1475
1476
1477
1478
1479   will cause accented characters to be displayed comme {,c}a.  If your
1480   keymap does not make it easy to produce non-ASCII characters, then
1481
1482
1483                (load-library "iso-transl")
1484
1485
1486
1487
1488   will make the 2-character sequence Ctrl-X 8 a compose character, so
1489   that the 4-character sequence Ctrl-X 8 , c produces c-cedilla.  Very
1490   inconvenient.
1491
1492   The command
1493
1494
1495                (iso-accents-mode)
1496
1497
1498
1499
1500   will toggle ISO-8859-1 accent mode, in which the six characters ', `,
1501   ", ^, ~, / are dead keys modifying the following symbol.  Special com-
1502   binations: ~c gives a c with cedilla, ~d gives an Icelandic eth, ~t
1503   gives an Icelandic thorn, "s gives German sharp s, /a gives a with
1504   ring, /e gives an a-e ligature, ~< and ~> give guillemots, ~! gives an
1505   inverted exclamation mark, ~? gives an inverted question mark, and ''
1506   gives an acute accent.  This is the default mapping of accents.  The
1507   variable iso-languages is a list of pairs (language name, accent map-
1508   ping), and a non-default mapping can be selected using
1509
1510
1511                (iso-accents-customize LANGUAGE)
1512
1513
1514
1515
1516   Here LANGUAGE can be one of "portuguese", "irish", "french",
1517   "latin-2", "latin-1".
1518
1519   Since the Linux default compose character is Ctrl-.  it might be
1520   convenient to use that everywhere. Try
1521
1522
1523                (load-library "iso-insert.el")
1524                (define-key global-map [?\C-.] 8859-1-map)
1525
1526
1527
1528
1529   The latter line will not work under xterm, if you use emacs -nw, but
1530   in that case you can put
1531
1532
1533                XTerm*VT100.Translations:       #override\n\
1534                      Ctrl <KeyPress> . : string("\0308")
1535
1536
1537
1538
1539   in your .Xresources.)
1540
1541   B. For less, put LESSCHARSET=latin1 in the environment.  This is also
1542   what you need if you see \255 or <AD> in man output: some versions of
1543   less will render the soft hyphen (octal 0255, hex 0xAD) this way when
1544   not given permission to output Latin-1.
1545
1546   C. For ls, give the option -N. (Probably you want to make an alias.)
1547
1548   D. For bash (version 1.13.*), put
1549
1550
1551                set meta-flag on
1552                set convert-meta off
1553                set output-meta on
1554
1555
1556
1557
1558   into your $HOME/.inputrc.
1559
1560   E. For tcsh, use
1561
1562
1563                setenv LANG     US_en
1564                setenv LC_CTYPE iso_8859_1
1565
1566
1567
1568
1569   If you have nls on your system, then the corresponding routines are
1570   used.  Otherwise tcsh will assume iso_8859_1, regardless of the values
1571   given to LANG and LC_CTYPE. See the section NATIVE LANGUAGE SYSTEM in
1572   tcsh(1).  (The Danish HOWTO says: setenv LC_CTYPE ISO-8859-1; stty
1573   pass8)
1574
1575   F. For flex, give the option -8 if the parser it generates must be
1576   able to handle 8-bit input. (Of course it must.)
1577
1578   G. For elm, set displaycharset to ISO-8859-1.  (Danish HOWTO: LANG=C
1579   and LC_CTYPE=ISO-8859-1)
1580
1581   H. For programs using curses (such as lynx) David Sibley reports: The
1582   regular curses package uses the high-order bit for reverse video mode
1583   (see flag _STANDOUT defined in /usr/include/curses.h).  However,
1584   ncurses seems to be 8-bit clean and does display iso-latin-8859-1
1585   correctly.
1586
1587   I. For programs using groff (such as man), make sure to use -Tlatin1
1588   instead of -Tascii. Old versions of the program man also use col, and
1589   the next point also applies.
1590
1591   J. For col, make sure 1) that it is fixed so as to do
1592   setlocale(LC_CTYPE,""); and 2) put LC_CTYPE=ISO-8859-1 in the
1593   environment.
1594
1595   K. For rlogin, use option -8.
1596
1597   L. For joe,
1598   metalab.unc.edu:/pub/Linux/apps/editors/joe-1.0.8-linux.tar.gz is said
1599   to work after editing the configuration file. Someone else said: joe:
1600   Put the -asis option in /isr/lib/joerc in the first column.
1601
1602   M. For LaTeX: \documentstyle[isolatin]{article}.  For LaTeX2e:
1603   \documentclass{article}\usepackage{isolatin} where isolatin.sty is
1604   available from ftp.vlsivie.tuwien.ac.at/pub/8bit.
1605
1606   A nice discussion on the topic of ISO-8859-1 and how to manage 8-bit
1607   characters is contained in the file grasp.insa-
1608   lyon.fr:/pub/faq/fr/accents (in French). Another fine discussion (in
1609   English) can be found in rtfm.mit.edu:pub/usenet-by-
1610   group/comp.answers/internationalization/iso-8859-1-charset.
1611
1612   If you need to fix a program that behaves badly with 8-bit characters,
1613   one thing to keep in mind is that if you have a signed char type then
1614   characters may be negative, and using them as an array index will
1615   fail.  Several programs can be fixed by judiciously adding (unsigned
1616   char) casts.
1617
1618
1619   1\b13\b3.\b.  X\bX
1620
1621
1622   This FAQ/HOWTO is about the Linux keyboard and console, not about X,
1623   which substitutes its own handling. However, it seems useful to
1624   document some of the Linux keyboard and console related properties of
1625   X.
1626
1627   First of all, when X is started (say using startx or xinit) it opens
1628   the first unused console, unless the desired console has been
1629   indicated explicitly, as in xinit -- vt12.  Note that this will fail
1630   when there is no device file /dev/tty12, but that it will not fail
1631   when the indicated console was in use already.  When X finishes, it
1632   will return to the original console.  While it is running one can use
1633   Ctrl-Alt-Fn to switch to VTn.
1634
1635   The XFree86 keymap mechanism is much poorer than the Linux mechanism.
1636   For each keycode there are at most 4 symbols defined, namely for the 4
1637   keymaps plain, shift, mod, mod+shift. What is the modifier mod?  It is
1638   the one designated by the symbol Mode_switch.  For example, the
1639   command xmodmap keys.dk, where the file keys.dk contains
1640
1641
1642        keycode 64 = Mode_switch
1643        keycode 113 = Mode_switch
1644        keycode 38 = a A aring Aring
1645        keycode 26 = e E ae AE
1646        keycode 32 = o O oslash Ooblique
1647
1648
1649
1650
1651   will make both Alt keys into mod keys, so that Alt+a gives  (a-ring),
1652   etc.  (Note the illogical naming of oslash and Ooblique.)  Such an
1653   xmodmap command can be placed in the .xinitrc shell script that is
1654   executed by default when X is started.
1655
1656
1657   1\b13\b3.\b.1\b1.\b.  W\bWh\bha\bat\bt p\bpr\bre\bec\bci\bis\bse\bel\bly\by d\bdo\boe\bes\bs X\bXF\bFr\bre\bee\be8\b86\b6-\b-2\b2.\b.1\b1 d\bdo\bo w\bwh\bhe\ben\bn i\bit\bt i\bin\bni\bit\bti\bia\bal\bli\biz\bze\bes\bs i\bit\bts\bs
1658   k\bke\bey\bym\bma\bap\bp?\b?
1659
1660
1661   Since version 2.1, XFree86 will initialize its keymap from the Linux
1662   keymap, as far as possible. However, Linux had 16 entries per key (one
1663   for each combination of the Shift, AltGr, Ctrl, Alt modifiers) and
1664   presently has 256 entries per key, while X has 4 entries per key (one
1665   for each combination of Shift, Mod), so some information is
1666   necessarily lost.
1667
1668   First X reads the Xconfig file, where definitions of the LeftAlt,
1669   RightAlt, RightCtl, ScrollLock keys as Meta, ModeShift, Compose,
1670   ModeLock or ScrollLock might be found - see X386keybd(1), later
1671   XFree86kbd(1).
1672
1673   For Mod the LeftAlt key is taken, unless RightCtl was defined as
1674   ModeShift or ModeLock, in which case RightCtl is taken, or RightAlt
1675   was so defined, in which case RightAlt is taken.  This determines how
1676   the 4 XFree86 meanings of a key are selected from the 16 Linux
1677   meanings.  Note that Linux today does not distinguish by default
1678   between the two Ctrl keys or between the two Shift keys. X does
1679   distinguish.
1680
1681   Now the kernel keymap is read and the usually obvious corresponding X
1682   bindings are made. The bindings for the "action keys" Show_Memory,
1683   Show_State, Show_Registers, Last_Console, Console_n, Scroll_Backward,
1684   Scroll_Forward, Caps_On and Boot are ignored, as are the dead
1685   diacriticals, and the locks (except for ShiftLock), and the "ASCII-x"
1686   keys.
1687
1688   Next, the definitions in the Xconfig file are used. (Thus, a
1689   definition of Compose in Xconfig will override its value as found in
1690   the Linux keymap.)
1691
1692   What happens to the strings associated with the function keys?
1693   Nothing, X does not have such a concept. (But it is possible to define
1694   strings for function keys in xterm - note however that the window
1695   manager gets the keys first.)
1696
1697   I don't know how to convince xterm that it should use the X keymap
1698   when Alt is pressed; it seems just to look at its resource
1699   eightBitInput, and depending on whether that is true or false either
1700   set the high order bit of the character, or generate an additional
1701   Escape character (just like setmetamode(1) does for the console).
1702
1703
1704   1\b14\b4.\b.  U\bUn\bnu\bus\bsu\bua\bal\bl k\bke\bey\bys\bs a\ban\bnd\bd k\bke\bey\byb\bbo\boa\bar\brd\bds\bs
1705
1706
1707   The two keys PrintScrn/SysRq and Pause/Break are special in that they
1708   have two keycodes: the former has keycode 84 when Alt is pressed
1709   simultaneously, and keycode 99 otherwise; the latter has keycode 101
1710   when Ctrl is pressed simultaneously, and keycode 119 otherwise.
1711   (Thus, it makes no sense to bind functions to Alt keycode 99 or Ctrl
1712   keycode 119.)
1713
1714   If you have strange keys, that do not generate any code under Linux
1715   (or generate messages like "unrecognized scancode"), and your kernel
1716   is 1.1.63 or later, then you can use setkeycodes(1) to tell the kernel
1717   about them. They won't work under X, however.  Once they have gotten a
1718   keycode from setkeycodes, they can be assigned a function by loadkeys.
1719
1720
1721   1\b15\b5.\b.  E\bEx\bxa\bam\bmp\bpl\ble\bes\bs o\bof\bf u\bus\bse\be o\bof\bf l\blo\boa\bad\bdk\bke\bey\bys\bs a\ban\bnd\bd x\bxm\bmo\bod\bdm\bma\bap\bp
1722
1723
1724   Switching Caps Lock and Control on the keyboard (assuming you use
1725   keymaps 0-15; check with dumpkeys | head -1)
1726
1727
1728                % loadkeys
1729                keymaps 0-15
1730                keycode 58 = Control
1731                keycode 29 = Caps_Lock
1732                %
1733
1734
1735
1736
1737   Switching them under X only:
1738
1739
1740                % xmodmap .xmodmaprc
1741
1742
1743
1744
1745   where .xmodmaprc contains lines
1746
1747
1748                remove Lock = Caps_Lock
1749                remove Control = Control_L
1750                keysym Control_L = Caps_Lock
1751                keysym Caps_Lock = Control_L
1752                add Lock = Caps_Lock
1753                add Control = Control_L
1754
1755
1756
1757
1758   What is this about the key numbering? Backspace is 14 under Linux, 22
1759   under X?  Well, the numbering can best be regarded as arbitrary; the
1760   Linux number of a key can be found using showkey(1), and the X number
1761   using xev(1). Often the X number will be 8 more than the Linux number.
1762
1763   Something else people like to change are the bindings of the function
1764   keys.  Suppose that you want to make F12 produce the string "emacs ".
1765   Then
1766
1767
1768                % loadkeys
1769                keycode 88 = F12
1770                string F12 = "emacs "
1771                %
1772
1773
1774
1775
1776   will do this. More explicitly, the procedure is like this: (i) find
1777   the keycodes of the keys to be remapped, using showkey(1).  (ii) save
1778   the current keymap, make a copy and edit that:
1779
1780
1781
1782
1783           % dumpkeys > my_keymap
1784           % cp my_keymap trial_keymap
1785           % emacs trial_keymap
1786           % loadkeys trial_keymap
1787           %
1788
1789
1790
1791
1792   The format of the table can be guessed by looking at the output of
1793   dumpkeys, and is documented in keymaps(5).  When the new keymap func-
1794   tions as desired, you can put an invocation
1795
1796
1797                loadkeys my_new_keymap
1798
1799
1800
1801
1802   in /etc/rc.local or so, to execute it automatically at boot-up.  Note
1803   that changing modifier keys is tricky, and a newbie can easily get
1804   into a situation only an expert can get out of.
1805
1806   The default directory for keymaps is /usr/lib/kbd/keymaps.  The
1807   default extension for keymaps is .map.  For example, loadkeys uk would
1808   probably load /usr/lib/kbd/keymaps/i386/qwerty/uk.map.  (With kbd-0.95
1809   and older this would be /usr/lib/kbd/keytables and
1810   /usr/lib/kbd/keytables/uk.map.)
1811
1812
1813   (On my machine) /dev/console is a symbolic link to /dev/tty0, and the
1814   kernel regards /dev/tty0 as a synonym for the current VT.  XFree86 1.3
1815   changes the owner of /dev/tty0, but does not reset this after
1816   finishing. Thus, loadkeys or dumpkeys might fail because someone else
1817   owns /dev/tty0; in such a case you might run X first.  Note that you
1818   cannot change keyboard mappings when not at the console (and not
1819   superuser).
1820
1821
1822   1\b15\b5.\b.1\b1.\b.  `\b`I\bI c\bca\ban\bn u\bus\bse\be o\bon\bnl\bly\by o\bon\bne\be f\bfi\bin\bng\bge\ber\br t\bto\bo t\bty\byp\bpe\be w\bwi\bit\bth\bh'\b'
1823
1824
1825   "Can the Shift, Ctrl and Alt keys be made to behave as toggles?"
1826
1827   Yes, after saying
1828
1829
1830                % loadkeys
1831                keymaps 0-15
1832                keycode 29 = Control_Lock
1833                keycode 42 = Shift_Lock
1834                keycode 56 = Alt_Lock
1835                %
1836
1837
1838
1839
1840   the left Control, Shift and Alt keys will act as toggles.  The numbers
1841   involved are revealed by showkey (and usually are 29, 97, 42, 54, 56,
1842   100 for left and right control, shift and alt, respectively), and the
1843   functions are Control_Lock, Shift_Lock, Alt_Lock, ALtGr_Lock.
1844
1845   "What about `sticky' modifier keys?"
1846
1847   Since version 1.3.33, the kernel knows about `sticky' modifier keys.
1848   These act on the next key pressed. So, where one earlier needed the
1849   3-symbol sequence Shift_Lock a Shift_Lock to type `A', one can now use
1850   the 2-symbol sequence SShift_Lock a.  Versions of the kbd package
1851   older than 0.93 do not yet include code for these sticky modifiers,
1852   and have to invoke them using their hexadecimal codes. For example,
1853
1854
1855                % loadkeys
1856                keymaps 0-15
1857                keycode 54 = 0x0c00
1858                keycode 97 = 0x0c02
1859                keycode 100 = 0x0c03
1860                %
1861
1862
1863
1864
1865   will make the right Shift, Ctrl, Alt sticky versions of the left ones.
1866   From 0.93 on you can say
1867
1868
1869                % loadkeys
1870                keymaps 0-15
1871                keycode 54 = SShift
1872                keycode 97 = SCtrl
1873                keycode 100 = SAlt
1874                %
1875
1876
1877
1878
1879   to obtain the same result.  This will allow you to type Ctrl-Alt-Del
1880   in three keystrokes with one hand.
1881
1882   The keymaps line in these examples should cover all keymaps you have
1883   in use.  You find what keymaps you have in use by
1884
1885
1886                % dumpkeys | head -1
1887
1888
1889
1890
1891
1892   1\b16\b6.\b.  C\bCh\bha\ban\bng\bgi\bin\bng\bg t\bth\bhe\be v\bvi\bid\bde\beo\bo m\bmo\bod\bde\be
1893
1894
1895   As far as I know there are 6 ways to change resolution:
1896
1897   1. At compile time: change the line
1898
1899
1900                SVGA_MODE=      -DSVGA_MODE=NORMAL_VGA
1901
1902
1903
1904
1905   in /usr/src/linux/Makefile.
1906
1907   1A. After compilation: use rdev -v - a terrible hack, but it exists.
1908
1909   2. At boot time: put vga=ask in the lilo config file, and lilo will
1910   ask you what video mode you want. Once you know, put vga=mypreference.
1911
1912   3. At run time: A. Use the resizecons command. (This is a very
1913   primitive wrapper around the VT_RESIZE ioctl.)  B. Use the
1914   SVGATextMode command. (This is a less primitive wrapper around the
1915   VT_RESIZE ioctl.)
1916
1917   4. Not "on the console": Under dosemu, or with svgalib etc. you can
1918   change the hardware video mode without the console driver being aware
1919   of it. Sometimes this is useful in getting resizecons or SVGATextMode
1920   set up: use dosemu and some DOS program to get into the desired
1921   videomode, dump (say from another VT) the contents of all video
1922   hardware registers, and use that in the initialization that resizecons
1923   and SVGATextMode require.  In some cases where the video mode has
1924   gotten into some unusable state, starting dosemu, relying on the BIOS
1925   to set up the video mode, and then killing dosemu (with kill -9), is
1926   the easiest way to get into shape again.
1927
1928
1929   1\b16\b6.\b.1\b1.\b.  I\bIn\bns\bst\btr\bru\buc\bct\bti\bio\bon\bns\bs f\bfo\bor\br t\bth\bhe\be u\bus\bse\be o\bof\bf r\bre\bes\bsi\biz\bze\bec\bco\bon\bns\bs
1930
1931
1932   Get svgalib and compile the program restoretextmode.  Boot up your
1933   machine in all possible video modes (using vga=ask in the lilo config
1934   file), and write the video hardware register contents to files CxR
1935   (C=cols, R=rows), e.g., 80x25, 132x44, etc.  Put these files in
1936   /usr/lib/kbd/videomodes.  Now resizecons 132x44 will change videomode
1937   for you (and send SIGWINCH to all processes that need to know about
1938   this, and load another font if necessary).
1939
1940   At present, resizecons only succeeds when there is memory enough for
1941   both the old and the new consoles at the same time.
1942
1943
1944   1\b17\b7.\b.  C\bCh\bha\ban\bng\bgi\bin\bng\bg t\bth\bhe\be k\bke\bey\byb\bbo\boa\bar\brd\bd r\bre\bep\bpe\bea\bat\bt r\bra\bat\bte\be
1945
1946
1947   At startup, the Linux kernel sets the repeat rate to its maximal
1948   value.  For most keyboards this is reasonable, but for some it means
1949   that you can hardly touch a key without getting three copies of the
1950   corresponding symbol. Use the program kbdrate(8) to change the repeat
1951   rate, or, if that doesn't help, edit or remove the section
1952
1953   ______________________________________________________________________
1954        ! set the keyboard repeat rate to the max
1955
1956            mov     ax,#0x0305
1957            xor     bx,bx           ! clear bx
1958            int     0x16
1959   ______________________________________________________________________
1960
1961
1962   of /usr/src/linux/[arch/i386/]boot/setup.S.
1963
1964   Scott Johnston (sj@zule.com) reports: `To program the repeat rate of a
1965   Gateway AnyKey keyboard all one has to do is press the "Repeat Rate"
1966   key, then a function key F1-F8, then "Repeat Rate" again.  F1 is the
1967   slowest possible repeat rate, and F8 is really fast.  If you somehow
1968   manage to mess up your AnyKey keyboard doing this, simply press Ctrl-
1969   Alt-SuspndMacro to reset your keyboard to factory default settings.'
1970
1971
1972   1\b18\b8.\b.  S\bSc\bcr\bro\bol\bll\bli\bin\bng\bg
1973
1974
1975   There are two ways to get a screen to scroll.  The first, called `hard
1976   scrolling', is to leave the text in video memory as it is, but change
1977   the viewing origin. This is very fast.  The second, called `soft
1978   scrolling', involves moving all screen text up or down. This is much
1979   slower.  The kernel console driver will write text starting at the top
1980   of the video memory, continuing to the bottom, then copy the bottom
1981   part to the top again, and continue, all the time using hard scrolling
1982   to show the right part on the screen.  You can scroll back until the
1983   top op the video memory by using Shift-PageUp (the grey PageUp) and
1984   scroll down again using Shift-PageDown (the grey PageDown), assuming a
1985   default keymap.  The amount of scrollback is thus limited to the
1986   amount of video memory you happen to have and you cannot increase this
1987   amount.  If you need more scrollback, use some program that buffers
1988   the text, like less or screen - by using a buffer on disk you can go
1989   back to what you did last week.  (One can set the amount of scrollback
1990   for xterm by adding a line like XTerm*saveLines: 2500 in .Xresources.)
1991
1992   Upon changing virtual consoles, the screen content of the old VT is
1993   copied to kernel memory, and the screen content of the new VT is
1994   copied from kernel memory to video memory. Only the visible screen is
1995   copied, not all of video memory, so switching consoles means losing
1996   the scrollback information.
1997
1998   Sometimes, hard scrolling is undesirable, for example when the
1999   hardware does not have the possibility to change viewing origin. The
2000   first example was a Braille machine that would render the top of video
2001   memory in Braille. There is a kernel boot-time option no-scroll to
2002   tell the console driver not to use hard scrolling.  See bootparam(7).
2003
2004
2005   1\b19\b9.\b.  S\bSc\bcr\bre\bee\ben\bns\bsa\bav\bvi\bin\bng\bg
2006
2007
2008   setterm -blank _\bn_\bn will tell the console driver to blank the screen
2009   after _\bn_\bn minutes of inactivity. (With _\bn_\bn = 0, screensaving is turned
2010   off. In some old kernels this first took effect after the next
2011   keyboard interrupt.)
2012
2013   The s option of xset(1) will set the X screensaving parameters: xset s
2014   off turns off the screensaver, xset s 10 blanks the screen after 10
2015   minutes.
2016
2017   The video hardware powersaving modes can be enabled/disabled using the
2018   setvesablank program given in the starting comment of
2019   /usr/src/linux/drivers/char/vesa_blank.c.
2020
2021
2022   2\b20\b0.\b.  S\bSc\bcr\bre\bee\ben\bn d\bdu\bum\bmp\bps\bs
2023
2024
2025   setterm -dump _\bN will dump the contents of the screen of /dev/tty_\bN to a
2026   file screen.dump in the current directory. See setterm(1).
2027
2028   The current contents of the screen of /dev/tty_\bN can be accessed using
2029   the device /dev/vcs_\bN (where `vcs' stands for `virtual console
2030   screen').  For example, you could have a clock program that displays
2031   the current time in the upper right hand corner of the console screen
2032   (see the program vcstime in kbd-0.99.tar.gz).  Just dumping the
2033   contents goes with cat /dev/vcs_\bN.  These device files /dev/vcs_\bN do not
2034   contain newlines, and do not contain attributes, like colors. From a
2035   program it is usually better to use /dev/vcsa_\bN (`virtual console
2036   screen with attributes') instead - it starts with a header giving the
2037   number of rows and columns and the location of the cursor.  See
2038   vcs(4).
2039
2040
2041   2\b21\b1.\b.  S\bSo\bom\bme\be p\bpr\bro\bop\bpe\ber\brt\bti\bie\bes\bs o\bof\bf t\bth\bhe\be V\bVT\bT1\b10\b00\b0 -\b- a\bap\bpp\bpl\bli\bic\bca\bat\bti\bio\bon\bn k\bke\bey\by m\bmo\bod\bde\be
2042
2043
2044   : Sometimes my cursor keys or keypad keys produce strange codes?
2045
2046
2047   When the terminal is in application cursor key mode the cursor keys
2048   produce  Esc O x  and otherwise  Esc [ x  where x is one of A,B,C,D.
2049   Certain programs put the terminal in application cursor key mode; if
2050   you kill them with kill -9, or if they crash, then the mode will not
2051   be reset.
2052
2053           % echo -e '\033c'
2054
2055
2056   resets all properties of the current VC. Just changing the cursor
2057   application key mode is done by
2058
2059           % echo -e '\033[?1h'
2060
2061
2062   (set) and
2063
2064           % echo -e '\033[?1l'
2065
2066
2067   (clear).
2068
2069   When the terminal is in application keypad key mode the keypad keys
2070   produce  Esc O y  and otherwise  Esc [ z ~  for certain y and z.
2071   Setting application keypad key mode is done by
2072
2073           % echo -e '\033='
2074
2075
2076   and
2077
2078           % echo -e '\033>'
2079
2080
2081   clears it again.
2082
2083
2084   2\b22\b2.\b.  H\bHa\bar\brd\bdw\bwa\bar\bre\be i\bin\bnc\bco\bom\bmp\bpa\bat\bti\bib\bbi\bil\bli\bit\bty\by
2085
2086
2087   Several people have noticed that they lose typed characters when a
2088   floppy disk is active. It seems that this might be a problem with
2089   Uni-486WB motherboards.
2090
2091   Tjalling Tjalkens (tjalling@ei.ele.tue.nl) reports very similar
2092   problems with "a no-brand GMB-486 UNP Vesa motherboard with AMD
2093   486DX2-66 CPU" - during floppy activity some keystrokes are lost,
2094   during floppy tape streamer (Conner C 250 MQ) activity many keystrokes
2095   are lost.
2096
2097   Some people experience sporadic lockups - sometimes associated to hard
2098   disk activity or other I/O.
2099
2100   Ulf Tietz (ulf@rio70.bln.sni.de) wrote: `I have had the same problems,
2101   when I had my motherboard tuned too fast.  So I reset all the timings
2102   ( CLK, wait statements etc ) to more conventional values, and the
2103   problems are gone.'
2104
2105   Bill Hogan (bhogan@crl.com) wrote: `If you have an AMI BIOS, you might
2106   try setting the Gate A20 emulation parameter to "chipset" (if you have
2107   that option). Whenever I have had that parameter set to any of the
2108   other options on my machine ("fast", "both", "disabled") I have had
2109   frequent keyboard lockups.'
2110
2111   There may be a relation between keyboard problems and the video card
2112   in use.
2113   Shawn K. Quinn (skquinn@wt.net) wrote: `I have a Zeos Pantera
2114   Pentium-90 that originally came with a Diamond Stealth 64 S3-based
2115   video card. Under X I frequently got q's inserted into my text (how
2116   annoying) especially if I typed very fast (during Netrek for instance,
2117   even more annoying because guess what that does :-( ).  Switching to a
2118   Creative Labs Graphics Blaster MA202 solved the problem.  I'm assuming
2119   the Stealth 64 did something funny with the timings.'
2120
2121
2122   2\b23\b3.\b.  C\bCo\bop\bpy\byr\bri\big\bgh\bht\bt
2123
2124   Copyright (c) 1993-1999 by Andries Brouwer.  This document may be
2125   distributed under the terms set forth in the LDP license at
2126   http://metalab.unc.edu/LDP/COPYRIGHT.html or
2127   ftp://www.win.tue.nl/pub/linux/LDP/COPYRIGHT.txt.
2128
2129   Additions and corrections are welcome.  Andries Brouwer - aeb@cwi.nl
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178