The cLIeNUX keyboard

Linux keyboard utilities are distributed in a package currently called kbd-0.99. It has lots of docs, including an excellent FAQ, with answers for most of the well-known snags encountered in Linux vis-a-vis backspace-delete confusion and so on, as well as most of the utilities mentioned here.

Aspects of the console keyboard specific to cLIeNUX are documented here.

A PC keyboard sends various byte values to the kernel when you hit the various keys. showkey is a nifty little program that tells you what the kernel sees from each keystroke. showkey takes over the keyboard driver, and puts it in raw mode, and will quit and return you to normal operation if you hit no keys for 10 seconds. The byte values the keyboard sends are called keycodes in the keymap files. My PS/2 101-key keyboard produces these keycodes...



   1   59 60 61 62  63 64 65 66  67 68 87 88  99 70 119    [LEDs]

      
   41 2  3  4  5  6  7  8  9  10 11 12 13 14   110 102 104  69 98 55 74 
   
   15  16 17 18 19 20 21 22 23 24 25 26 27 43  111 107 109  71 72 73 78

   58   30 31 32 33 34 35 36 37 38 39 40   28               75 76 77       

   42    44 45 46 47 48 49 50 51 52 53     54      103	    79 80 81 96
  
   29     56           57           100    97  105 108 106  82    83

... which I think is fairly standard. That's what the kernel sees of the keyboard, basically. The kernel is normally not in raw mode. Normally it's in XLATE mode, translate. That's what the keymap files are about. They define the current translation. The default Linux keyboard translation map file is /subroutine/defkeymap.map which is the stock qwerty layout, and is the default layout the kernel boots to if not told otherwise.

The keyboard mapping can be modified or completely changed with the loadkeys command. I currently use the dvorak.map layout, and am working on a very unusual layout of my own. If you look at /subroutine/defkeymap.map you can see that it equates keycodes to keysyms. Keysyms are the actions the kernel performs on specified keys and combinations, and Linux has a very rich set of these actions. The dumpkeys utility will show you what mapping is currently in effect, and has a -l switch to list all available keysyms, or kernel actions. Keysyms are 2-byte values, with related names. There are numerical ranges of keysyms, and the known keysyms in each range are grouped by type of action. Here is a synopsis of the ranges dumpkeys -l shows me with 2.2.10...


        0x0000 - 0x00ff  - normal ASCII and "hi-ASCII" or "ANSI"
        0x0100 - 0x01ff  - 256 function strings or definable hotkeys 
        0x0200 - 0x0213  - system commands like reboot, show processes
        0x0300 - 0x0313  - keypad functions
        0x0400 - 0x0405  - deadkeys, accent the following key
        0x0500 - 0x05ff  - change to vt #, 63 possible
        0x0600 - 0x0603  - arrows Up Down Left Right
        0x0700 - 0x0708  - modifiers, like shift, there are 8
        0x0800 - 0x08ff  - ASCII 0x00-0xff range plus a meta byte and bit
        0x0900 - 0x0919  - ascii and hex, allow inputting raw bytes
        0x0a00 - 0x0a07  - locks
        0x0b00 - 0x0bff  - unused
        0x0c00 - 0x0c07  - sticky modifiers, one-finger shift etc.