  The Linux keyboard and console HOWTO
  Andries Brouwer, aaeebb@@ccwwii..nnll
  v2.4, 970326

  This note contains some information about the Linux keyboard and
  console, and the use of non-ASCII characters.  It describes Linux 2.0.

  11..  UUsseeffuull pprrooggrraammss


  The following packages contain keyboard or console related programs.

  kkbbdd--00..9933..ttaarr..ggzz contains llooaaddkkeeyyss, dduummppkkeeyyss, sshhoowwkkeeyy, sseettmmeettaammooddee,
  sseettlleeddss, sseettffoonntt, sshhoowwffoonntt, mmaappssccrrnn, kkbbdd__mmooddee, llooaadduunniimmaapp, cchhvvtt,
  rreessiizzeeccoonnss, ddeeaallllooccvvtt, ggeettkkeeyyccooddeess, sseettkkeeyyccooddeess.

  uuttiill--lliinnuuxx--22..66 contains sseetttteerrmm, kkbbddrraattee.  (Yes, the mmoorree in uuttiill--
  lliinnuuxx--22..66 dumps core due to a name conflict. Preserve your old copy,
  or use uuttiill--lliinnuuxx--22..55, or change `savetty' to `my_savetty' in mmoorree..cc.)

  sshh--uuttiillss--11..1122 contains ssttttyy.

  ooppeenn--11..44..ttggzz contains ooppeenn (that should be renamed to ooppeennvvtt). (See
  also ddyynnaammiicc--vvcc--11..11..ttaarr..ggzz.)

  SSVVGGAATTeexxttMMooddee--11..44..ttaarr..ggzz contains SSVVGGAATTeexxttMMooddee, a program that
  obsoletes rreessiizzeeccoonnss.

  The X distribution contains xxmmooddmmaapp, xxsseett, kkbbdd__mmooddee.  (See also
  X386keybd(1) for the situation under XFree86 1.3, and Xserver(1) for
  the XKEYBOARD extension under X11R6.)

  tteerrmmccaapp--22..00..88..ttaarr..ggzz contains tteerrmmccaapp, an old terminal capabilities
  data base. nnccuurrsseess--11..99..99ee..ttaarr..ggzz contains the tteerrmmlliibb data base which
  obsoletes tteerrmmccaapp. (However, there are still many programs using
  tteerrmmccaapp.)

  See loadkeys(1), setleds(1) and setmetamode(1) for the codes generated
  by the various keys and the setting of leds when not under X. Under X,
  see xmodmap(1) and xset(1).

  See setfont(8) for loading console fonts. Many people will want to
  load a font like iissoo0011..ff1166 because the default font is the hardware
  font of the video card, and often is a `Code Page 437' font missing
  accented characters and other Latin-1 symbols.

  See setterm(1) and kbdrate(8) for properties such as foreground and
  background colors, screen blanking and character repeat rate when not
  under X.  Under X, see xset(1), also for key click and bell volume.

  The file //eettcc//tteerrmmccaapp defines the escape sequences used by many
  programs addressing the console (or any other terminal).  See
  termcap(5).  A more modern version is found in //uussrr//lliibb//tteerrmmiinnffoo.  See
  terminfo(5). Terminfo files are compiled by the terminfo compiler
  //uussrr//lliibb//tteerrmmiinnffoo//ttiicc, see tic(1).  Their contents can be examined
  using the program iinnffooccmmpp, see infocmp(1).  The Linux console
  sequences are documented in console_codes(4).



  22..  KKeeyybbooaarrdd ggeenneerraalliittiieess


  You press a key, and the keyboard controller sends scancodes to the
  kernel keyboard driver. Some keyboards can be programmed, but usually
  the scancodes corresponding to your keys are fixed.  The kernel
  keyboard driver just transmits whatever it receives to the application
  program when it is in _s_c_a_n_c_o_d_e _m_o_d_e, like when XX is running.
  Otherwise, it parses the stream of scancodes into keycodes,
  corresponding to key press or key release events.  (A single key press
  can generate up to 6 scancodes.)  These keycodes are transmitted to
  the application program when it is in _k_e_y_c_o_d_e _m_o_d_e (as used, for
  example, by sshhoowwkkeeyy).  Otherwise, these keycodes are looked up in the
  keymap, and the character or string found there is transmitted to the
  application, or the action described there is performed.  (For
  example, if one presses and releases the aa key, then the keyboard
  produces scancodes 0x1e and 0x9e, this is converted to keycodes 30 and
  158, and then transmitted as 0141, the ASCII or latin-1 code for `a';
  if one presses and releases DDeelleettee, then the keyboard produces
  scancodes 0xe0 0x53 0xe0 0xd3, these are converted to keycodes 111 and
  239, and then transmitted as the 4-symbol sequence ESC [ 3 ~, all
  assuming a US keyboard and a default keymap. An example of a key
  combination to which an action is assigned is Ctrl-Alt-Del.)

  The translation between unusual scancodes and keycodes can be set
  using the utility sseettkkeeyyccooddeess - only very few people will need it.
  The translation between keycodes and characters or strings or actions,
  that is, the keymap, is set using the utilities llooaaddkkeeyyss and
  sseettmmeettaammooddee.  For details, see getkeycodes(8), setkeycodes(8),
  dumpkeys(1), loadkeys(1), setmetamode(1). The format of the files
  output by dduummppkkeeyyss and read by llooaaddkkeeyyss is described in keytables(5).

  Where it says `transmitted to the application' in the above
  description, this really means `transmitted to the terminal driver'.
  That is, further processing is just like that of text that comes in
  over a serial line.  The details of this processing are set by the
  program ssttttyy.


  33..  CCoonnssoollee ggeenneerraalliittiieess


  Conversely, when you output something to the console, it first
  undergoes the standard tty processing, and then is fed to the console
  driver.  The console driver emulates a VT100, and parses the input in
  order to recognize VT100 escape sequences (for cursor movement, clear
  screen, etc.).  The characters that are not part of an escape sequence
  are first converted into Unicode, using one of four mapping tables if
  the console was not in UTF-8 mode to start with, then looked up in the
  table describing the correspondence between Unicode values and font
  positions, and the obtained 8- or 9-bit font indices are then written
  to video memory, where they cause the display of character shapes
  found in the video card's character ROM.  One can load one's own fonts
  into character ROM using sseettffoonntt, load the corresponding Unicode map
  with llooaadduunniimmaapp, and load a user mapping table using mmaappssccrrnn.  More
  details will be given below.

  There are many consoles (called _V_i_r_t_u_a_l _C_o_n_s_o_l_e_s or _V_i_r_t_u_a_l _T_e_r_m_i_n_a_l_s,
  abbreviated VCs or VTs) that share the same screen. You can use them
  as independent devices, either to run indendent login sessions, or
  just to send some output to, perhaps from ttoopp, or the tail of the
  system log or so.  See below (`Console switching') on how to set them
  up and switch between them.



  44..  RReesseettttiinngg yyoouurr tteerrmmiinnaall


  There is garbage on the screen, or all your keystrokes are echoed as
  line drawing characters. What to do?

  Many programs will redraw the screen when ^L is typed. This might help
  when there is some modem noise or broadcast message on your screen.
  The command cclleeaarr will clear the screen.

  The command rreesseett will reset the console driver. This helps when the
  screen is full of funny graphic characters, and also if it is reduced
  to the bottom line. If you don't have this command, or if it does
  something else, make your own by putting the following two lines in an
  executable file rreesseett in your PATH:

               #!/bin/sh
               echo -e \\033c



  that is, you want to send the two characters ESC c to the console.

  Why is it that the display sometimes gets confused and gives you a
  24-line or 1-line screen, instead of the usual 25 lines?  Well, the
  main culprit is the use of TTEERRMM==vvtt110000 (or some other entry with 24
  lines) instead of TTEERRMM==lliinnuuxx when logged in remotely.  If this happens
  on //ddeevv//ttttyy22 then typing

               % cat > /dev/tty2
               ^[c
               ^D



  on some other VT (where 4 symbols are typed to ccaatt: ESC, c, ENTER,
  Ctrl-D) and refreshing the screen on //ddeevv//ttttyy22 (perhaps using ^L) will
  fix things. Of course the permanent fix is to use the right termcap or
  terminfo entry.

  Why is it that you sometimes get a lot of line-drawing characters,
  e.g., after catting a binary to the screen?  Well, there are various
  character set changing escape sequences, and by accident your binary
  might contain some of these.  The ESC c is a general reset, a cure for
  all, but if you know precisely what went wrong you can repair it
  without resetting other console attributes. For example, after

               % cat
               ^N
               ^D



  your shell prompt will be all line-drawing characters.  Now do (typing
  blindly)

               % cat
               ^O
               ^D



  and all is well again. (Three symbols typed to each ccaatt: ^N (or ^O),
  ENTER, Ctrl-D.) To understand what is happening, see `The console
  character sets' below.

  If you loaded some strange font, and want to return to the default,

               % setfont



  will do (provided you stored the default font in the default place).
  If this default font does not contain an embedded Unicode map (and
  gives the wrong symbols for accented characters), then say

               % loadunimap



  For example, if I do

               % loadkeys de-latin1



  then I have a German keyboard, and the key left of the Enter key gives
  me a-umlaut. This works, because the a-umlaut occurs on the CP437 code
  page and the kernel Unicode map is initialized to CP437, and my video
  card has a CP437 font built-in.  If I now load an ISO 8859-1 font with

               % setfont iso01.f16



  then everything still works, because sseettffoonntt invalidates the kernel
  Unicode map (if there is no Unicode map attached to the font), and
  without map the kernel goes directly to the font, and that is
  precisely correct for an ISO 8859-1 system with iissoo0011..ff1166 font.  But
  going back to the previous font with

               % setfont



  gives capital Sigma's instead of a-umlaut - all accented letters are
  mixed up because also this font has no embedded Unicode map. After

               % loadunimap



  which loads the default Unicode map (which is right for the default
  font) all works correctly again. Usually llooaadduunniimmaapp is not invoked
  directly, but via sseettffoonntt. Thus, the previous two commands may be
  replaced by

               % setfont -u def



  The Ethiopian fonts and the llaatt11uu**..ppssff fonts have embedded Unicode
  code map. Most of the others don't.

  On old terminals output involving tabs may require a delay, and you
  have to say

               % stty tab3



  (see stty(1)).

  You can change the video mode using rreessiizzeeccoonnss or SSVVGGAATTeexxttMMooddee.  This
  usually settles the output side.  On the input side there are many
  things that might be wrong. If XX or DDOOOOMM or some other program using
  raw mode crashed, your keyboard may still be in raw (or mediumraw)
  mode, and it is difficult to give commands.  (See "How to get out of
  raw mode" below.)  If you loaded a bad keymap, then

               % loadkeys -d



  loads the default map again, but it may well be difficult to type `-'!
  An alternative is

               % loadkeys defkeymap



  Sometimes even the letters are garbled. It is useful to know that
  there are four main types of keyboards: QWERTY, QWERTZ, AZERTY and
  DVORAK.  The first three are named after the first six letter keys,
  and roughly represent the English, German and French speaking
  countries.  Compared to QWERTY, the QWERTZ map interchanges Y and Z.
  Compared to QWERTY, the AZERTY map interchanges Q and A, W and Z, and
  has its M right of the L, at the semicolon position.  DVORAK has an
  entirely different letter ordering.


  44..11..  KKeeyybbooaarrdd hhaarrddwwaarree rreesseett


  Things may be wrong on a lower level than Linux knows about.  There
  are at least two distinct lower levels (keyboard and keyboard
  controller) where one can give the command "keyboard disable" to the
  keyboard hardware.  Keyboards can often be programmed to use one out
  of three different sets of scancodes.

  However, I do not know of cases where this turned out to be a problem.

  Some keyboards have a remapping capability built in.  Stormy Henderson
  (ssttoorrmmyy@@GGhhoosstt..NNeett) writes: `If it's your keyboard accidently being
  reprogrammed, you can (on a Gateway AnyKey keyboard) press control-
  alt-suspend_macro to reset the keys to normal.'


  55..  DDeelleettee aanndd BBaacckkssppaaccee


  Getting Delete and Backspace to work just right is nontrivial,
  especially in a mixed environment, where you talk to console, to XX, to
  bbaasshh, to eemmaaccss, login remotely, etc.  You may have to edit several
  configuration files to tell all of the programs involved precisely
  what you want.  On the one hand, there is the matter of which keys
  generate which codes (and how these codes are remapped by e.g. kkeerrmmiitt
  or eemmaaccss), and on the other hand the question of what functions are
  bound to what codes.

  People often complain `my backspace key does not work', as if this key
  had a built-in function `delete previous character'.  Unfortunately,
  all this key, or any key, does is producing a code, and one only can
  hope that the kernel tty driver and all application programs can be
  configured such that the backspace key indeed does function as a
  `delete previous character' key.

  Most Unix programs get their tty input via the kernel tty driver in
  `cooked' mode, and a simple ssttttyy command determines the erase
  character. However, programs like bbaasshh and eemmaaccss and XX do their own
  input handling, and have to be convinced one-by-one to do the right
  thing.


  55..11..  HHooww ttoo tteellll UUnniixx wwhhaatt cchhaarraacctteerr yyoouu wwaanntt ttoo uussee ttoo ddeelleettee tthhee
  llaasstt ttyyppeedd cchhaarraacctteerr



               % stty erase ^?



  If the character is erased, but in a funny way, then something is
  wrong with your tty settings. If eecchhoopprrtt is set, then erased
  characters are enclosed between \\ and //.  If eecchhooee is not set, then
  the erase char is echoed (which is reasonable when it is a printing
  character, like #).  Most people will want ssttttyy eecchhooee --eecchhoopprrtt. Saying
  ssttttyy ssaannee will do this and more. Saying ssttttyy --aa shows your current
  settings.  How come this is not right by default? It is, if you use
  the right ggeettttyy.

  Note that many programs (like bbaasshh, eemmaaccss etc.) have their own
  keybindings (defined in ~~//..iinnppuuttrrcc, ~~//..eemmaaccss etc.) and are unaffected
  by the setting of the erase character.

  The standard Unix tty driver does not recognize a cursor, or keys
  (like the arrow keys) to move the current position, and hence does not
  have a command `delete current character' either. But for example you
  can get bbaasshh on the console to recognize the Delete key by putting

               set editing-mode emacs
               "\e[3~":delete-char



  into ~~//..iinnppuuttrrcc.


  55..11..11..  ``GGeettttyy uusseedd ttoo ddoo tthhee rriigghhtt tthhiinngg wwiitthh DDEELL aanndd BBSS bbuutt iiss
  bbrrookkeenn nnooww??''


  Earlier, the console driver would do BS Space BS (\\001100\\004400\\001100) when
  it got a DEL (\\117777).  Nowadays, DEL's are ignored (as they should be,
  since the driver emulates a vt100). Get a better getty, i.e., one that
  does not output DEL.


  55..11..22..  ``LLooggiinn bbeehhaavveess ddiiffffeerreennttllyy aatt tthhee ffiirrsstt aanndd sseeccoonndd llooggiinn
  aatttteemmppttss??''


  At the first attempt, you are talking to ggeettttyy. At the second attempt,
  you are talking to llooggiinn, a different program.


  55..22..  HHooww ttoo tteellll LLiinnuuxx wwhhaatt ccooddee ttoo ggeenneerraattee wwhheenn aa kkeeyy iiss pprreesssseedd


  On the console, or, more precisely, when not in (MEDIUM)RAW mode, use

               % loadkeys mykeys.map



  and under X use

               % xmodmap mykeys.xmap

  Note that (since XFree86-2.1) X reads the Linux settings of the
  keymaps when initialising the X keymap. Although the two systems are
  not 100% compatible, this should mean that in many cases the use of
  xxmmooddmmaapp has become superfluous.

  For example, suppose that you would like the Backspace key to send a
  BackSpace (^H, octal 010) and the grey Delete key a DEL (octal 0177).
  Add the following to //eettcc//rrcc..llooccaall (or wherever you keep your local
  boot-time stuff):

               /usr/bin/loadkeys << EOF
               keycode 14 = BackSpace
               keycode 111 = Delete
               EOF



  Note that this will only change the function of these keys when no
  modifiers are used. The Linux kernel default lets Ctrl-Backspace
  generate BackSpace - this is sometimes useful as emergency escape,
  when you find you can only generate DELs.

  The left Alt key is sometimes called the Meta key, and by default the
  combinations AltL-X are bound to the symbol MetaX.  But what character
  sequence is MetaX?  That is determined (per-tty) by the Meta flag, set
  by the command sseettmmeettaammooddee. The two choices are: ESC X or X or-ed with
  0200.


  55..22..11..  ``WWhhyy ddooeessnn''tt tthhee BBaacckkssppaaccee kkeeyy ggeenneerraattee BBaacckkSSppaaccee bbyy ddeeffaauulltt??''


  (i) Because the VT100 had a Delete key above the Enter key.

  (ii) Because Linus decided so.


  55..33..  HHooww ttoo tteellll XX ttoo iinntteerrcchhaannggee DDeelleettee aanndd BBaacckkssppaaccee



               % xmodmap -e "keysym BackSpace = Delete" -e "keysym Delete = BackSpace"



  Or, if you just want the Backspace key to generate a BackSpace:

               % xmodmap -e "keycode 22 = BackSpace"



  Or, if you just want the Delete key to generate a Delete:

               % xmodmap -e "keycode 107 = Delete"



  (but usually this is the default binding already).


  55..44..  HHooww ttoo tteellll eemmaaccss wwhhaatt ttoo ddoo wwhheenn iitt rreecceeiivveess aa DDeelleettee oorr
  BBaacckkssppaaccee


  Put in your ..eemmaaccss file lines like

          (global-set-key "\?" 'help-command)
          (global-set-key "\C-h" 'delete-backward-char)



  Of course you can bind other commands to other keys in the same way.
  Note that various major and minor modes redefine keybindings.  For
  example, in incremental search mode one finds the code

               (define-key map "\177" 'isearch-delete-char)
               (define-key map "\C-h" 'isearch-mode-help)



  This means that it may be a bad idea to use the above two global-set-
  key commands. There are too many places where there are built-in
  assumptions about ^H = help and DEL = delete.  That doesn't mean that
  you have to setup keys so that Backspace generates DEL. But if it
  doesn't then it is easiest to remap them at the lowest possible level
  in emacs.


  55..55..  HHooww ttoo tteellll eemmaaccss ttoo iinntteerrcchhaannggee DDeelleettee aanndd BBaacckkssppaaccee


  Put in your ..eemmaaccss file lines

               (setq keyboard-translate-table (make-string 128 0))
               (let ((i 0))
                 (while (< i 128)
                   (aset keyboard-translate-table i i)
                   (setq i (1+ i))))
               (aset keyboard-translate-table ?\b ?\^?)
               (aset keyboard-translate-table ?\^? ?\b)



  Recent versions of emacs have a function kkeeyybbooaarrdd--ttrraannssllaattee and one
  may simplify the above to

               (keyboard-translate ?\C-h ?\C-?)
               (keyboard-translate ?\C-? ?\C-h)



  Note that under X emacs can distinguish between Ctrl-h and the
  Backspace key (regardless of what codes these produce on the console),
  and by default emacs will view the Backspace key as DEL (and do
  deletion things, as bound to that character, rather than help thing,
  bound to ^H).


  55..66..  HHooww ttoo tteellll kkeerrmmiitt ttoo iinntteerrcchhaannggee DDeelleettee aanndd BBaacckkssppaaccee


  Put in your ..kkeerrmmrrcc file the lines

               set key \127 \8
               set key \8 \127







  55..77..  HHooww ttoo tteellll xxtteerrmm aabboouutt yyoouurr ffaavvoouurriittee ttttyy mmooddeess


  Normally xterm will inherit the tty modes from its invoker.  Under
  xxddmm, the default erase and kill characters are ## and @@, as in good old
  Unix Version 6.  If you don't like that, you might put something like

               XTerm*ttymodes: erase ^? kill ^U intr ^C quit ^\ eof ^D \
                               susp ^Z start ^Q stop ^S eol ^@



  in //uussrr//lliibb//XX1111//aapppp--ddeeffaauullttss//XXTTeerrmm or in $$HHOOMMEE//..XXrreessoouurrcceess, assuming
  that you have a line

               xrdb $HOME/.Xresources



  in your $$HHOOMMEE//..xxiinniittrrcc.


  55..88..  HHooww ttoo tteellll xxmmoossaaiicc tthhaatt tthhee BBaacckkssppaaccee kkeeyy ggeenneerraatteess aa DDEELL


  Putting

               *XmText.translations: #override\n\
                  <Key>osfDelete: delete-previous-character()
               *XmTextField.translations: #override\n\
                  <Key>osfDelete: delete-previous-character()



  in your $$HHOOMMEE//..XXrreessoouurrcceess helps.

  The netscape FAQ, however, says:
          Why doesn't my Backspace key work in text fields?
          By default, Linux and XFree86 come with the Backspace and Delete keys
          misconfigured. All Motif programs (including, of course, Netscape
          Navigator) will malfunction in the same way.

          The Motif spec says that Backspace is supposed to delete the previous
          character and Delete is supposed to delete the following character.
          Linux and XFree86 come configured with both the Backspace and Delete
          keys generating Delete.

          You can fix this by using any one of the xmodmap, xkeycaps, or
          loadkeys programs to make the key in question generate the BackSpace
          keysym instead of Delete.

          You can also fix it by having a .motifbind file; see the man page
          for VirtualBindings(3).

          Note: Don't use the *XmText.translations or *XmTextField.translations
          resources to attempt to fix this problem. If you do, you will blow
          away Netscape Navigator's other text-field key bindings.



  55..99..  WWhhaatt aabboouutt tteerrmmccaapp aanndd tteerrmmiinnffoo??


  When people have problems with backspace, they tend to look at their
  termcap (or terminfo) entry for the terminal, and indeed, there does
  exist a kb (or kbs) capability describing the code generated by the
  Backspace key.  However, not many programs use it, so unless you are
  having problems with one particular program only, probably the fault
  is elsewhere.  Of course it is a good idea anyway to correct your
  termcap (terminfo) entry.  See also below under "The TERM variable".


  66..  TThhee ccoonnssoollee cchhaarraacctteerr sseettss


  The kernel first tries to figure out what symbol is meant by any given
  user byte, and next where this symbol is located in the current font.

  The kernel knows about 5 translations of bytes into console-screen
  symbols.  In Unicode (UTF-8) mode, the UTF-8 code is just converted
  directly into Unicode. The assumption is that almost all symbols one
  needs are present in Unicode, and for the cases where this does not
  hold the codes 0xff** are reserved for direct font access.  When not
  in Unicode mode, one of four translation tables is used.  The four
  tables are: a) Latin1 -> Unicode,  b) VT100 graphics -> Unicode, c) PC
  -> Unicode, d) user-defined.

  There are two character sets, called G0 and G1, and one of them is the
  current character set. (Initially G0.)  Typing ^N causes G1 to become
  current, ^O causes G0 to become current.

  These variables G0 and G1 point at a translation table, and can be
  changed by the user. Initially they point at tables a) and b),
  respectively.  The sequences ESC ( B and ESC ( 0 and ESC ( U and ESC (
  K cause G0 to point at translation table a), b), c) and d),
  respectively.  The sequences ESC ) B and ESC ) 0 and ESC ) U and ESC )
  K cause G1 to point at translation table a), b), c) and d),
  respectively.

  The sequence ESC c causes a terminal reset, which is what you want if
  the screen is all garbled. The oft-advised eecchhoo ^^VV^^OO will only make G0
  current, but there is no guarantee that G0 points at table a).  In
  some distributions there is a program reset(1) that just does eecchhoo
  ^^[[cc.  If your termcap entry for the console is correct (and has an
  entry ::rrss==\\EEcc::), then also sseetttteerrmm --rreesseett will work.

  The user-defined mapping table can be set using mapscrn(8).  The
  result of the mapping is that if a symbol c is printed, the symbol ss ==
  mmaapp[[cc]] is sent to the video memory. The bitmap that corresponds to ss
  is found in the character ROM, and can be changed using setfont(8).


  77..  CCoonnssoollee sswwiittcchhiinngg


  By default, console switching is done using Alt-Fn or Ctrl-Alt-Fn.
  Under XX (or recent versions of ddoosseemmuu), only Ctrl-Alt-Fn works.  Many
  keymaps will allow cyclic walks through all allocated consoles using
  Alt-RightArrow and Alt-LeftArrow.

  XFree86 1.3 does not know that Alt is down when you switch to the X
  window. Thus, you cannot switch immediately to some other VT again but
  have to release Alt first.  In the other direction this should work:
  the kernel always keeps track of the up/down status of all keys. (As
  far as possible: on some keyboards some keys do not emit a scancode
  when pressed (e.g.: the PFn keys of a FOCUS 9000) or released (e.g.:
  the Pause key of many keyboards).)

  XFree86 1.3 saves the fonts loaded in the character ROMs when started,
  and restores it on a console switch. Thus, the result of sseettffoonntt on a
  VT is wiped out when you go to X and back.  Using sseettffoonntt under X will
  lead to funny results.
  One can change VT under program control using the cchhvvtt command.


  77..11..  CChhaannggiinngg tthhee nnuummbbeerr ooff VViirrttuuaall CCoonnssoolleess


  This question still comes up from time to time, but the answer is: you
  already have enough of them.  Since kernel version 1.1.54, there are
  between 1 and 63 virtual consoles. A new one is created as soon as it
  is opened. It is removed by the utility ddeeaallllooccvvtt (but it can be
  removed only when no processes are associated to it anymore, and no
  text on it has been selected by programs like sseelleeccttiioonn or ggppmm).

  For older kernels, change the line

               #define NR_CONSOLES     8



  in iinncclluuddee//lliinnuuxx//ttttyy..hh (don't increase this number beyond 63), and
  recompile the kernel.

  If they do not exist yet, create the tty devices with MMAAKKEEDDEEVV or mmkknnoodd
  ttttyyN cc 44 N where N denotes the tty number. For example,

               for i in 9 10 11 12; do mknod /dev/tty$i c 4 $i; done



  or, better (since it also takes care of owner and permissions),

               for i in 9 10 11 12; do /dev/MAKEDEV tty$i; done



  If you want the new VCs to run ggeettttyy, add lines in //eettcc//iinniittttaabb.  (But
  it is much better to have only two ggeettttyy's running, and to create more
  consoles dynamically as the need arises.  That way you'll have more
  memory when you don't use all these consoles, and also more consoles,
  in case you really need them.  Edit //eettcc//iinniittttaabb and comment out all
  ggeettttyy's except for the first two.)

  When the consoles are allocated dynamically, it is usually easiest to
  have only one or two running ggeettttyy. More are opened by ooppeenn --ll --ss
  bbaasshh. Unused consoles (without associated processes) are deallocated
  using ddeeaallllooccvvtt (formerly ddiissaalllloocc).  But, you say, I am involved in
  activities when I suddenly need more consoles, and do not have a bash
  prompt available to give the ooppeenn command.  Fortunately it is possible
  to create a new console upon a single keystroke, regardless of what is
  happening at the current console.

  If you have ssppaawwnn__llooggiinn from kkbbdd--00..9933..ttaarr..ggzz and you put

               loadkeys << EOF
               alt keycode 103 = Spawn_Console
               EOF
               spawn_login &



  in //eettcc//rrcc..llooccaall, then typing Alt-UpArrow will create a fresh VC
  running llooggiinn (and switch to it). With ssppaawwnn__ccoonnssoollee && instead of
  ssppaawwnn__llooggiinn && you'll have bash running there.  See also ooppeenn--11..44..ttggzz
  and ddyynnaammiicc--vvcc--11..11..ttaarr..ggzz.


  What action should be taken upon this Spawn_Console keypress can also
  be set in //eettcc//iinniittttaabb under kkbbrreeqquueesstt, if you have a recent iinniitt. See
  inittab(5).  (The action can be something entirely different - I just
  called the key Spawn_Console because that is what I used it for.)

  You can only login as "root" on terminals listed in //eettcc//sseeccuurreettttyy.
  There exist programs that read terminal settings from files //eettcc//ttttyyss
  and //eettcc//ttttyyttyyppee. If you have such files, and create additional
  consoles, then it might be a good idea to also add entries for them in
  these files.


  88..  CCttrrll--AAlltt--DDeell aanndd ootthheerr ssppeecciiaall kkeeyy ccoommbbiinnaattiioonnss



  88..11..  CCttrrll--AAlltt--DDeell ((BBoooott))

  If you press Ctrl-Alt-Del (or whatever key was assigned the keysym
  Boot by loadkeys) then either the machine reboots immediately (without
  sync), or iinniitt is sent a SIGINT. The former behaviour is the default.
  The default can be changed by root, using the system call reboot(),
  see ctrlaltdel(8).  Some iinniitt's change the default. What happens when
  iinniitt gets SIGINT depends on the version of iinniitt used - often it will
  be determined by the pf entry in //eettcc//iinniittttaabb (which means that you
  can run an arbitrary program in this case).  In the current kernel
  Ctrl-AltGr-Del is no longer by default assigned to Boot.


  88..22..  OOtthheerr ccoommbbiinnaattiioonnss

  Name            Default binding
  -------------------------------
  Show_Memory     Shift-Scrollock
  Show_Registers  AltGr-ScrollLock
  Show_State      Ctrl-ScrollLock
  Console_n       Alt-Fn and Ctrl-Alt-Fn  (1 <= n <= 12)
  Console_{n+12}  AltGr-Fn                (1 <= n <= 12)
  Incr_Console    Alt-RightArrow
  Decr_Console    Alt-LeftArrow
  Last_Console    Alt[Gr]-PrintScreen
  Scroll_Backward Shift-PageUp
  Scroll_Forward  Shift-PageDown
  Caps_On                                 (CapsLock is a toggle; this key sets)
  Compose         Ctrl-.



  88..33..  XX CCoommbbiinnaattiioonnss

  Ctrl-Alt-Fn     Switch to VT n
  Ctrl-Alt-KP+    Next mode
  Ctrl-Alt-KP-    Previous mode
  Ctrl-Alt-Backspace      Kill X

  On some motherboards, Ctrl-Alt-KP- and Ctrl-Alt-KP+ will be equivalent
  to pressing the Turbo button. That is, both will produce the scancodes
  1d 38 4a ca b8 9d and 1d 38 4e ce b8 9d, and both will switch between
  Turbo (>= 25MHz) and non-Turbo (8 or 12 MHz).  (Often these key
  combinations only function this way when enabled by jumpers on the
  motherboard.)

  Perry F Nguyen (ppffnngguuyyeenn@@nneettccoomm2222..nneettccoomm..ccoomm) writes: AMI BIOS has a
  feature that locks up the keyboard and flashes the LED's if the Ctrl-
  Alt-Backspace combination is pressed while a BIOS password is enabled,
  until the CMOS/BIOS password is typed in.
  88..44..  DDoosseemmuu CCoommbbiinnaattiioonnss

  Ctrl-Alt-Fn     Switch to VT n (from version 0.50; earlier Alt-Fn)
  Ctrl-Alt-PgDn   Kill dosemu (when in RAW keyboard mode)
  (and many other combinations - see the dosemu documentation)



  88..55..  CCoommppoossiinngg ssyymmbboollss


  One symbol may be constructed using several keystrokes.

     LeftAlt-press, followed by a decimal number typed on the keypad,
     followed by LeftAlt-release, yields the symbol with code given by
     this number.  (In Unicode mode this same mechanism, but then with 4
     hexadecimal digits, may be used to define a Unicode symbol.)

     A dead diacritic followed by a symbol, yields that symbol adorned
     with that diacritic. If the combination is undefined, both keys are
     taken separately.  Which keys are dead diacritics is user-settable;
     none is by default.  Five (since 2.0.25 six) dead diacritics can be
     defined (using loadkeys(1)): dead_grave, dead_acute,
     dead_circumflex, dead_tilde, dead_diaeresis (and dead_cedilla).
     Precisely what this adorning means is also user-settable: dead-
     diacritic, symbol is equivalent to Compose + diacritic + symbol.

     Compose followed by two symbols yields a combination symbol. These
     combinations are user-settable. Today there are 68 combinations
     defined by default; you can see them by saying "dumpkeys | grep
     compose".

     Then there are `Sticky' modifier keys (since 1.3.33). For example,
     one can type ^C as SControl, C and Ctrl-Alt-BackSpace as SControl,
     SAlt, BackSpace.

  Note that there are at least three such composition mechanisms:

  1. The Linux keyboard driver mechanism, used in conjunction with
     loadkeys.

  2. The X mechanism - see X386keybd(1), later XFree86kbd(1).  Under
     X11R6: edit //uussrr//XX1111RR66//lliibb//XX1111//llooccaallee//iissoo88885599--11//CCoommppoossee.

  3. The emacs mechanism obtained by loading "iso-insert.el" or calling
     `iso-accents-mode'.

     For X the order of the two symbols is arbitrary: both Compose-,-c
     and Compose-c-, yield a c-cedilla; for Linux and emacs only the
     former sequence works by default. For X the list of compose
     combinations is fixed. Linux and emacs are flexible.  The three
     default lists are somewhat similar, but the details are different.


  99..  HHooww ttoo ggeett oouutt ooff rraaww mmooddee


  If some program using K_RAW keyboard mode exits without restoring the
  keyboard mode to K_XLATE, then it is difficult to do anything - not
  even Ctrl-Alt-Del works. However, it is sometimes possible to avoid
  hitting the reset button.  (And desirable as well: your users may get
  angry if you kill their Hack game by rebooting; you might also damage
  your file system.)  Easy solutions involve logging in from another
  terminal or another machine and doing kkbbdd__mmooddee --aa.  The procedure
  below assumes that no X is running, that the display is in text mode,
  and that you are at your bash prompt, that you are using a US keyboard
  layout, and that your interrupt character is Ctrl-C.

  Step 1. Start X.  As follows: press 2 (and don't release), press F12
  (and don't release) and immediately afterwards press = . This starts
  X.  (Explanation: if a key press produces keycode K, then the key
  release produces keycode K+128. Probably your shell does not like
  these high characters, so we avoid generating them by not releasing
  any key.  However, we have to be quick, otherwise key repeat starts.
  The digit 2 produces a Ctrl-C that discards previous junk, the F12
  produces an X and the = a Return.)  Probably your screen will be grey
  now, since no ..xxiinniittrrcc was specified.  However, Ctrl-Alt-Fn will work
  and you can go to another VT.  (Ctrl-Alt-Backspace also works, but
  that exits X, and gets you back into the previous state, which is not
  what you want.)

  Step 2. Setup to change the keyboard mode.  (For example, by sslleeeepp 55;;
  kkbbdd__mmooddee --aa.)

  Step 3. Leave X again.  Alt-Fx (often Alt-F7) brings you back to X,
  and then Ctrl-Alt-Backspace exits X. Within 5 seconds your keyboard
  will be usable again.

  If you want to prepare for the occasion, then make \\221155AA\\330011 (3
  symbols) an alias for kkbbdd__mmooddee --aa.  Now just hitting = F7 = (3
  symbols) will return you to sanity.


  1100..  TThhee kkeeyybbooaarrdd LLEEDDss


  1. There are per-tty keyboard flags: each VC has its own NumLock,
  CapsLock, ScrollLock.  By default these keyboard flags are shown in
  the LEDs.  The usual way to change them is by pressing the
  corresponding key.  (Side remark: pressing the NumLock key when in
  application key mode will not change the NumLock status, but produce
  an escape sequence.  If you want the NumLock key to always change the
  Numlock status, bind it to Bare_Num_Lock.)

  2. Next, there are per-tty default keyboard flags, to initialize the
  keyboard flags when a reset occurs.  Thus if you want NumLock on all
  the time, that is possible.  The usual way to change them is by
  `sseettlleeddss --DD ...'.

  3. There is the possibility that the leds do not reflect the keyboard
  flags, but something else.

  3A. This something else can be three bits somewhere in the kernel -
  which can be used if you want to monitor some hardware or software
  status bit(s). If you want this, edit the kernel source to call
  rreeggiisstteerr__lleeddss(()) somewhere.

  3B. This something else can also be whatever some user program wants
  to show in the LEDs. Thus, people who like such things can make nice
  patterns of lights. If you want this, use the KDSETLED ioctl.

  This latter use is not per-tty, but the choice between former and
  latter use is per-tty.

  Summarizing: Each tty has a flag kkbbdd-->>lleeddmmooddee.  If this has the value
  LED_SHOW_FLAGS then the keyboard flags (NumLock etc.) of that tty are
  shown.  If this has the value LED_SHOW_MEM then three selected memory
  addresses are shown.  If this has the value LED_SHOW_IOCTL then the
  leds show whatever value was last assigned to them using the KDSETLED
  ioctl.


  One may add that X uses ioctl's to set the LEDs, but fails to reset
  its VT when it exits, so after using X there may be one VT that is not
  in the default LED_SHOW_FLAGS state.  This can be fixed by doing
  `sseettlleeddss --LL' on that VT.  See setleds(1).


  1111..  TThhee TTEERRMM vvaarriiaabbllee


  Many programs use the TTEERRMM variable and the database //eettcc//tteerrmmccaapp or
  //uussrr//lliibb//tteerrmmiinnffoo//** to decide which strings to send for clear screen,
  move cursor, etc., and sometimes also to decide which string is sent
  by the users backspace key, function keys etc.  This value is first
  set by the kernel (for the console).  Usually, this variable is re-set
  by ggeettttyy, using //eettcc//ttttyyttyyppee or the argument specified in
  //eettcc//iinniittttaabb.  Sometimes, it is also set in //eettcc//pprrooffiillee.

  Older systems use TTEERRMM==ccoonnssoollee or TTEERRMM==ccoonn8800xx2255. Newer systems (with
  ncurses 1.8.6) use the more specific TTEERRMM==lliinnuuxx or TTEERRMM==lliinnuuxx--8800xx2255.
  However, old versions of sseetttteerrmm test for TTEERRMM==ccoonn** and hence fail to
  work with TTEERRMM==lliinnuuxx.

  Since kernel version 1.3.2, the kernel default for the console is
  TTEERRMM==lliinnuuxx.

  If you have a termcap without entry for linux, add the word linux to
  the entry for the console:

               console|con80x25|linux:\



  and make //uussrr//lliibb//tteerrmmiinnffoo//ll//lliinnuuxx a copy of or symbolic link to
  //uussrr//lliibb//tteerrmmiinnffoo//cc//ccoonnssoollee.


  1111..11..  TTeerrmmiinnffoo


  The terminfo entry for the linux console from ncurses 1.8.6 misses the
  entry kkiicchh11==\\EE[[22~~, needed by some programs.  Edit the file and ttiicc it.


  1122..  HHooww ttoo mmaakkee ootthheerr pprrooggrraammss wwoorrkk wwiitthh nnoonn--AASSCCIIII cchhaarrss


  In the bad old days this used to be quite a hassle. Every separate
  program had to be convinced individually to leave your bits alone.
  Not that all is easy now, but recently a lot of gnu utilities have
  learned to react to LLCC__CCTTYYPPEE==iissoo__88885599__11 or LLCC__CCTTYYPPEE==iissoo--88885599--11.  Try
  this first, and if it doesn't help look at the hints below.  Note that
  in recent versions of libc the routine setlocale() only works if you
  have installed the locale files (e.g. in //uussrr//lliibb//llooccaallee).

  First of all, the 8-th bit should survive the kernel input processing,
  so make sure to have ssttttyy ccss88 --iissttrriipp --ppaarreennbb set.

  A. For eemmaaccss the details strongly depend on the version.  The
  information below is for version 19.34. Put lines

               (set-input-mode nil nil 1)
               (standard-display-european t)
               (require 'iso-syntax)



  into your $$HHOOMMEE//..eemmaaccss.  The first line (to be precise: the final 1)
  tells eemmaaccss not to discard the 8-th bit from input characters.  The
  second line tells eemmaaccss not to display non-ASCII characters as octal
  escapes.  The third line specifies the syntactic properties and case
  conversion table for the Latin-1 character set These last two lines
  are superfluous if you have something like LLCC__CCTTYYPPEE==IISSOO--88885599--11 in your
  environment.  (The variable may also be LLCC__AALLLL or even LLAANNGG.  The
  value may be anything with a substring `88591' or `8859-1' or
  `8859_1'.)

  This is a good start.  On a terminal that cannot display non-ASCII ISO
  8859-1 symbols, the command

               (load-library "iso-ascii")



  will cause accented characters to be displayed comme {,c}a.  If your
  keymap does not make it easy to produce non-ASCII characters, then

               (load-library "iso-transl")



  will make the 2-character sequence Ctrl-X 8 a compose character, so
  that the 4-character sequence Ctrl-X 8 , c produces c-cedilla.  Very
  inconvenient.

  The command

               (iso-accents-mode)



  will toggle ISO-8859-1 accent mode, in which the six characters ', `,
  ", ^, ~, / are dead keys modifying the following symbol.  Special
  combinations: ~c gives a c with cedilla, ~d gives an Icelandic eth, ~t
  gives an Icelandic thorn, "s gives German sharp s, /a gives a with
  ring, /e gives an a-e ligature, ~< and ~> give guillemots, ~! gives an
  inverted exclamation mark, ~? gives an inverted question mark, and ''
  gives an acute accent.  This is the default mapping of accents.  The
  variable iissoo--llaanngguuaaggeess is a list of pairs (language name, accent
  mapping), and a non-default mapping can be selected using

               (iso-accents-customize LANGUAGE)



  Here LANGUAGE can be one of ""ppoorrttuugguueessee"", ""iirriisshh"", ""ffrreenncchh"",
  ""llaattiinn--22"", ""llaattiinn--11"".

  Since the Linux default compose character is Ctrl-.  it might be
  convenient to use that everywhere. Try

               (load-library "iso-insert.el")
               (define-key global-map [?\C-.] 8859-1-map)



  The latter line will not work under xxtteerrmm, if you use eemmaaccss --nnww, but
  in that case you can put

               XTerm*VT100.Translations:       #override\n\
                     Ctrl <KeyPress> . : string("\0308")


  in your ..XXrreessoouurrcceess.)

  B. For lleessss, put LLEESSSSCCHHAARRSSEETT==llaattiinn11 in the environment.  This is also
  what you need if you see \\225555 or <<AADD>> in mmaann output: some versions of
  lleessss will render the soft hyphen (octal 0255, hex 0xAD) this way when
  not given permission to output Latin-1.

  C. For llss, give the option --NN. (Probably you want to make an alias.)

  D. For bbaasshh (version 1.13.*), put

               set meta-flag on
               set convert-meta off



  and, according to the Danish HOWTO,

               set output-meta on



  into your $$HHOOMMEE//..iinnppuuttrrcc.

  E. For ttccsshh, use

               setenv LANG     US_en
               setenv LC_CTYPE iso_8859_1



  If you have nls on your system, then the corresponding routines are
  used.  Otherwise ttccsshh will assume iso_8859_1, regardless of the values
  given to LANG and LC_CTYPE. See the section NATIVE LANGUAGE SYSTEM in
  tcsh(1).  (The Danish HOWTO says: sseetteennvv LLCC__CCTTYYPPEE IISSOO--88885599--11;; ssttttyy
  ppaassss88)

  F. For fflleexx, give the option --88 if the parser it generates must be
  able to handle 8-bit input. (Of course it must.)

  G. For eellmm, set ddiissppllaayycchhaarrsseett to IISSOO--88885599--11.  (Danish HOWTO: LLAANNGG==CC
  and LLCC__CCTTYYPPEE==IISSOO--88885599--11)

  H. For programs using curses (such as llyynnxx) David Sibley reports: The
  regular curses package uses the high-order bit for reverse video mode
  (see flag _STANDOUT defined in //uussrr//iinncclluuddee//ccuurrsseess..hh).  However,
  nnccuurrsseess seems to be 8-bit clean and does display iso-latin-8859-1
  correctly.

  I. For programs using ggrrooffff (such as mmaann), make sure to use --TTllaattiinn11
  instead of --TTaasscciiii. Old versions of the program mmaann also use ccooll, and
  the next point also applies.

  J. For ccooll, make sure 1) that it is fixed so as to do
  sseettllooccaallee((LLCC__CCTTYYPPEE,,""""));; and 2) put LLCC__CCTTYYPPEE==IISSOO--88885599--11 in the
  environment.

  K. For rrllooggiinn, use option --88.

  L. For jjooee,
  ssuunnssiittee..uunncc..eedduu:://ppuubb//LLiinnuuxx//aappppss//eeddiittoorrss//jjooee--11..00..88--lliinnuuxx..ttaarr..ggzz is said
  to work after editing the configuration file. Someone else said: jjooee:
  Put the --aassiiss option in //iissrr//lliibb//jjooeerrcc in the first column.

  M. For LaTeX: \\ddooccuummeennttssttyyllee[[iissoollaattiinn]]{{aarrttiiccllee}}.  For LaTeX2e:
  \\ddooccuummeennttccllaassss{{aarrttiiccllee}}\\uusseeppaacckkaaggee{{iissoollaattiinn}} where iissoollaattiinn..ssttyy is
  available from ffttpp::////ffttpp..vvllssiivviiee..ttuuwwiieenn..aacc..aatt//ppuubb//88bbiitt.

  A nice discussion on the topic of ISO-8859-1 and how to manage 8-bit
  characters is contained in the file ggrraasspp..iinnssaa--
  llyyoonn..ffrr:://ppuubb//ffaaqq//ffrr//aacccceennttss (in French). Another fine discussion (in
  English) can be found in ffttpp..vvllssiivviiee..ttuuwwiieenn..aacc..aatt:://ppuubb//88bbiitt//FFAAQQ--
  IISSOO--88885599--11, which is mirrored in rrttffmm..mmiitt..eedduu::ppuubb//uusseenneett--bbyy--
  ggrroouupp//ccoommpp..aannsswweerrss//cchhaarraacctteerr--sseettss//iissoo--88885599--11--ffaaqq.

  If you need to fix a program that behaves badly with 8-bit characters,
  one thing to keep in mind is that if you have a signed char type then
  characters may be negative, and using them as an array index will
  fail.  Several programs can be fixed by judiciously adding (unsigned
  char) casts.


  1133..  WWhhaatt pprreecciisseellyy ddooeess XXFFrreeee8866--22..11 ddoo wwhheenn iitt iinniittiiaalliizzeess iittss
  kkeeyymmaapp??


  Since version 2.1, XFree86 will initialize its keymap from the Linux
  keymap, as far as possible. However, Linux had 16 entries per key (one
  for each combination of the Shift, AltGr, Ctrl, Alt modifiers) and
  presently has 256 entries per key, while X has 4 entries per key (one
  for each combination of Shift, Mod), so some information is
  necessarily lost.

  First XX reads the XXccoonnffiigg file, where definitions of the LeftAlt,
  RightAlt, RightCtl, ScrollLock keys as Meta, ModeShift, Compose,
  ModeLock or ScrollLock might be found - see X386keybd(1), later
  XFree86kbd(1).

  For Mod the LeftAlt key is taken, unless RightCtl was defined as
  ModeShift or ModeLock, in which case RightCtl is taken, or RightAlt
  was so defined, in which case RightAlt is taken.  This determines how
  the 4 XFree86 meanings of a key are selected from the 16 Linux
  meanings.  Note that Linux today does not distinguish by default
  between the two Ctrl keys or between the two Shift keys. XX does
  distinguish.

  Now the kernel keymap is read and the usually obvious corresponding X
  bindings are made. The bindings for the "action keys" Show_Memory,
  Show_State, Show_Registers, Last_Console, Console_n, Scroll_Backward,
  Scroll_Forward, Caps_On and Boot are ignored, as are the dead
  diacriticals, and the locks (except for ShiftLock), and the "ASCII-x"
  keys.

  Next, the definitions in the XXccoonnffiigg file are used. (Thus, a
  definition of Compose in XXccoonnffiigg will override its value as found in
  the Linux keymap.)

  What happens to the strings associated with the function keys?
  Nothing, X does not have such a concept. (But it is possible to define
  strings for function keys in xxtteerrmm - note however that the window
  manager gets the keys first.)

  I don't know how to convince xxtteerrmm that it should use the X keymap
  when Alt is pressed; it seems just to look at its resource
  eeiigghhttBBiittIInnppuutt, and depending on whether that is true or false either
  set the high order bit of the character, or generate an additional
  Escape character (just like setmetamode(1) does for the console).





  1144..  UUnnuussuuaall kkeeyyss aanndd kkeeyybbooaarrddss


  The two keys PrintScrn/SysRq and Pause/Break are special in that they
  have two keycodes: the former has keycode 84 when Alt is pressed
  simultaneously, and keycode 99 otherwise; the latter has keycode 101
  when Ctrl is pressed simultaneously, and keycode 119 otherwise.
  (Thus, it makes no sense to bind functions to Alt keycode 99 or Ctrl
  keycode 119.)

  If you have strange keys, that do not generate any code under Linux
  (or generate messages like "unrecognized scancode"), and your kernel
  is 1.1.63 or later, then you can use setkeycodes(1) to tell the kernel
  about them. They won't work under X, however.  Once they have gotten a
  keycode from sseettkkeeyyccooddeess, they can be assigned a function by llooaaddkkeeyyss.


  1155..  EExxaammpplleess ooff uussee ooff llooaaddkkeeyyss aanndd xxmmooddmmaapp


  Switching Caps Lock and Control on the keyboard (assuming you use
  keymaps 0-15; check with dduummppkkeeyyss || hheeaadd --11)

               % loadkeys
               keymaps 0-15
               keycode 58 = Control
               keycode 29 = Caps_Lock
               %



  Switching them under X only:

               % xmodmap .xmodmaprc



  where ..xxmmooddmmaapprrcc contains lines

               remove Lock = Caps_Lock
               remove Control = Control_L
               keysym Control_L = Caps_Lock
               keysym Caps_Lock = Control_L
               add Lock = Caps_Lock
               add Control = Control_L



  What is this about the key numbering? Backspace is 14 under Linux, 22
  under X?  Well, the numbering can best be regarded as arbitrary; the
  Linux number of a key can be found using showkey(1), and the X number
  using xev(1). Often the X number will be 8 more than the Linux number.

  Something else people like to change are the bindings of the function
  keys.  Suppose that you want to make F12 produce the string "emacs ".
  Then

               % loadkeys
               keycode 88 = F12
               string F12 = "emacs "
               %



  will do this. More explicitly, the procedure is like this: (i) find
  the keycodes of the keys to be remapped, using showkey(1).  (ii) save
  the current keymap, make a copy and edit that:

               % dumpkeys > my_keymap
               % cp my_keymap trial_keymap
               % emacs trial_keymap
               % loadkeys trial_keymap
               %



  The format of the table can be guessed by looking at the output of
  dduummppkkeeyyss, and is documented in keytables(5).  When the new keymap
  functions as desired, you can put an invocation

               loadkeys my_new_keymap



  in //eettcc//rrcc..llooccaall or so, to execute it automatically at boot-up.  Note
  that changing modifier keys is tricky, and a newbie can easily get
  into a situation only an expert can get out of.

  The default directory for keymaps is //uussrr//lliibb//kkbbdd//kkeeyyttaabblleess.  The
  default extension for keymaps is ..mmaapp.  Thus, llooaaddkkeeyyss uukk would
  probably load //uussrr//lliibb//kkbbdd//kkeeyyttaabblleess//uukk..mmaapp.

  (On my machine) //ddeevv//ccoonnssoollee is a symbolic link to //ddeevv//ttttyy00, and the
  kernel regards //ddeevv//ttttyy00 as a synonym for the current VT.  XFree86 1.3
  changes the owner of //ddeevv//ttttyy00, but does not reset this after
  finishing. Thus, llooaaddkkeeyyss or dduummppkkeeyyss might fail because someone else
  owns //ddeevv//ttttyy00; in such a case you might run X first.  Note that you
  cannot change keyboard mappings when not at the console (and not
  superuser).


  1155..11..  ``II ccaann uussee oonnllyy oonnee ffiinnggeerr ttoo ttyyppee wwiitthh''


  "Can the Shift, Ctrl and Alt keys be made to behave as toggles?"

  Yes, after saying

               % loadkeys
               keycode 29 = Control_Lock
               keycode 42 = Shift_Lock
               keycode 56 = Alt_Lock
               %



  the left Control, Shift and Alt keys will act as toggles.  The numbers
  involved are revealed by showkey (and usually are 29, 97, 42, 54, 56,
  100 for left and right control, shift and alt, respectively), and the
  functions are Control_Lock, Shift_Lock, Alt_Lock, ALtGr_Lock.

  "What about `sticky' modifier keys?"

  Since version 1.3.33, the kernel knows about `sticky' modifier keys.
  These act on the next key pressed. So, where one earlier needed the
  3-symbol sequence Shift_Lock a Shift_Lock to type `A', one can now use
  the 2-symbol sequence SShift_Lock a.  Versions of the kbd package
  older than 0.93 do not yet include code for these sticky modifiers,
  and have to invoke them using their hexadecimal codes. For example,



          % loadkeys
          keymaps 0-15
          keycode 54 = 0x0c00
          keycode 97 = 0x0c02
          keycode 100 = 0x0c03
          %



  will make the right Shift, Ctrl, Alt sticky versions of the left ones.
  From 0.93 on you can say

               % loadkeys
               keymaps 0-15
               keycode 54 = SShift
               keycode 97 = SCtrl
               keycode 100 = SAlt
               %



  to obtain the same result.


  1166..  CChhaannggiinngg tthhee vviiddeeoo mmooddee


  As far as I know there are 6 ways to change resolution:

  1. At compile time: change the line

               SVGA_MODE=      -DSVGA_MODE=NORMAL_VGA



  in //uussrr//ssrrcc//lliinnuuxx//MMaakkeeffiillee.

  1A. After compilation: use rrddeevv --vv - a terrible hack, but it exists.

  2. At boot time: put vvggaa==aasskk in the lilo config file, and lilo will
  ask you what video mode you want. Once you know, put vvggaa==mypreference.

  3. At run time: A. Use the rreessiizzeeccoonnss command. (This is a very
  primitive wrapper around the VT_RESIZE ioctl.)  B. Use the
  SSVVGGAATTeexxttMMooddee command. (This is a less primitive wrapper around the
  VT_RESIZE ioctl.)

  4. Not "on the console": Under ddoosseemmuu, or with svgalib etc. you can
  change the hardware video mode without the console driver being aware
  of it. Sometimes this is useful in getting rreessiizzeeccoonnss or SSVVGGAATTeexxttMMooddee
  set up: use ddoosseemmuu and some DOS program to get into the desired
  videomode, dump (say from another VT) the contents of all video
  hardware registers, and use that in the initialization that rreessiizzeeccoonnss
  and SSVVGGAATTeexxttMMooddee require.  In some cases where the video mode has
  gotten into some unusable state, starting ddoosseemmuu, relying on the BIOS
  to set up the video mode, and then killing ddoosseemmuu (with kkiillll --99), is
  the easiest way to get into shape again.


  1166..11..  IInnssttrruuccttiioonnss ffoorr tthhee uussee ooff rreessiizzeeccoonnss


  Get svgalib and compile the program rreessttoorreetteexxttmmooddee.  Boot up your
  machine in all possible video modes (using vvggaa==aasskk in the lilo config
  file), and write the video hardware register contents to files CxR
  (C=cols, R=rows), e.g., 80x25, 132x44, etc.  Put these files in
  //uussrr//lliibb//kkbbdd//vviiddeeoommooddeess.  Now rreessiizzeeccoonnss 113322xx4444 will change videomode
  for you (and send SIGWINCH to all processes that need to know about
  this, and load another font if necessary).

  At present, rreessiizzeeccoonnss only succeeds when there is memory enough for
  both the old and the new consoles at the same time.


  1177..  CChhaannggiinngg tthhee kkeeyybbooaarrdd rreeppeeaatt rraattee


  At startup, the Linux kernel sets the repeat rate to its maximal
  value.  For most keyboards this is reasonable, but for some it means
  that you can hardly touch a key without getting three copies of the
  corresponding symbol. Use the program kbdrate(8) to change the repeat
  rate, or, if that doesn't help, edit or remove the section
  ______________________________________________________________________
       ! set the keyboard repeat rate to the max

           mov     ax,#0x0305
           xor     bx,bx           ! clear bx
           int     0x16
  ______________________________________________________________________

  of //uussrr//ssrrcc//lliinnuuxx//[[aarrcchh//ii338866//]]bboooott//sseettuupp..SS.


  1188..  SSccrroolllliinngg


  There are two ways to get a screen to scroll.  The first, called `hard
  scrolling', is to leave the text in video memory as it is, but change
  the viewing origin. This is very fast.  The second, called `soft
  scrolling', involves moving all screen text up or down. This is much
  slower.  The kernel console driver will write text starting at the top
  of the video memory, continuing to the bottom, then copy the bottom
  part to the top again, and continue, all the time using hard scrolling
  to show the right part on the screen.  You can scroll back until the
  top op the video memory by using Shift-PageUp (the grey PageUp) and
  scroll down again using Shift-PageDown (the grey PageDown), assuming a
  default keymap.  The amount of scrollback is thus limited to the
  amount of video memory you happen to have and you cannot increase this
  amount.  If you need more scrollback, use some program that buffers
  the text, like lleessss or ssccrreeeenn - by using a buffer on disk you can go
  back to what you did last week.  (One can set the amount of scrollback
  for xxtteerrmm by adding a line like XXTTeerrmm**ssaavveeLLiinneess:: 22550000 in ..XXrreessoouurrcceess.)

  Upon changing virtual consoles, the screen content of the old VT is
  copied to kernel memory, and the screen content of the new VT is
  copied from kernel memory to video memory. Only the visible screen is
  copied, not all of video memory, so switching consoles means losing
  the scrollback information.

  Sometimes, hard scrolling is undesirable, for example when the
  hardware does not have the possibility to change viewing origin. The
  first example was a Braille machine that would render the top of video
  memory in Braille. There is a kernel boot-time option nnoo--ssccrroollll to
  tell the console driver not to use hard scrolling.  See bootparam(7).


  1199..  SSccrreeeennssaavviinngg


  sseetttteerrmm --bbllaannkk _n_n will tell the console driver to blank the screen
  after _n_n minutes of inactivity. (With _n_n = 0, screensaving is turned
  off. In some old kernels this first took effect after the next
  keyboard interrupt.)

  The ss option of xset(1) will set the X screensaving parameters: xxsseett ss
  ooffff turns off the screensaver, xxsseett ss 1100 blanks the screen after 10
  minutes.

  The video hardware powersaving modes can be enabled/disabled using the
  sseettvveessaabbllaannkk program given in the starting comment of
  //uussrr//ssrrcc//lliinnuuxx//ddrriivveerrss//cchhaarr//vveessaa__bbllaannkk..cc.


  2200..  SSccrreeeenn dduummppss


  sseetttteerrmm --dduummpp _N will dump the contents of the screen of //ddeevv//ttttyy_N to a
  file ssccrreeeenn..dduummpp in the current directory. See setterm(1).

  The current contents of the screen of //ddeevv//ttttyy_N can be accessed using
  the device //ddeevv//vvccss_N (where `vcs' stands for `virtual console
  screen').  For example, you could have a clock program that displays
  the current time in the upper right hand corner of the console screen
  (see the program vvccssttiimmee in kkbbdd--00..9933..ttaarr..ggzz).  Just dumping the
  contents goes with ccaatt //ddeevv//vvccss_N.  These device files //ddeevv//vvccss_N do not
  contain newlines, and do not contain attributes, like colors. From a
  program it is usually better to use //ddeevv//vvccssaa_N (`virtual console
  screen with attributes') instead - it starts with a header giving the
  number of rows and columns and the location of the cursor.  See
  vcs(4).


  2211..  SSoommee pprrooppeerrttiieess ooff tthhee VVTT110000 -- aapppplliiccaattiioonn kkeeyy mmooddee


  : Sometimes my cursor keys or keypad keys produce strange codes?

  When the terminal is in application key mode the cursor keys produce
  Esc O x  and otherwise  Esc [ x  where x is one of A,B,C,D.  Certain
  programs put the terminal in application key mode; if you kill them
  with kkiillll --99, or if they crash, then the mode will not be reset.
          % echo -e '\033c'

  resets all properties of the current VC. Just changing the application
  key mode is done by
          % echo -e '\033[?1h'

  (set) and
          % echo -e '\033[?1l'

  (clear).


  2222..  HHaarrddwwaarree iinnccoommppaattiibbiilliittyy


  Several people have noticed that they lose typed characters when a
  floppy disk is active. It seems that this might be a problem with
  Uni-486WB motherboards.  (Please mail me (aaeebb@@ccwwii..nnll) to confirm [yes,
  I have the same problem], deny [no, nothing wrong with my Uni-486WB],
  modify [My Xyzzy machine has the same problem].)

  Tjalling Tjalkens (ttjjaalllliinngg@@eeii..eellee..ttuuee..nnll) reports very similar
  problems with "a no-brand GMB-486 UNP Vesa motherboard with AMD
  486DX2-66 CPU" - during floppy activity some keystrokes are lost,
  during floppy tape streamer (Conner C 250 MQ) activity many keystrokes
  are lost.

  Some people experience sporadic lockups - sometimes associated to hard
  disk activity or other I/O.

  Ulf Tietz (uullff@@rriioo7700..bbllnn..ssnnii..ddee) wrote: `I have had the same problems,
  when I had my motherboard tuned too fast.  So I reset all the timings
  ( CLK, wait statements etc ) to more conventional values, and the
  problems are gone.'

  Bill Hogan (bbhhooggaann@@ccrrll..ccoomm) wrote: `If you have an AMI BIOS, you might
  try setting the Gate A20 emulation parameter to "chipset" (if you have
  that option). Whenever I have had that parameter set to any of the
  other options on my machine ("fast", "both", "disabled") I have had
  frequent keyboard lockups.'

  --------------------------------------------------------------------

  Additions and corrections are welcome.  Andries Brouwer - aaeebb@@ccwwii..nnll

















































