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