1.Dd January 8, 1995 2.Dt KEYBOARD 4 3.Os FreeBSD 4.Sh NAME 5.Nm keyboard 6.Nd pc keyboard interface 7.Sh DESCRIPTION 8 9The PC keyboard is used as the console character input device. The keyboard 10is owned by the current virtual console. 11To switch between the virtual consoles use the sequence 12.Ar ALT+Fn 13, which means hold down ALT and press one of the function keys. The 14virtual console with the same number as the function key is then 15selected as the current virtual console, and given exclusive use of 16the keyboard and display. 17 18The console allows entering values that are not physically 19present on the keyboard via a special keysequence. 20To use this facility press and hold down ALT, 21then enter a decimal number from 0-255 via the numerical keypad, then 22release ALT. The entered value is then used as the ASCII value for one 23character. This way it is possible to enter any ASCII value, not present 24on the keyboard. 25The console driver also includes a history function. It is activated by 26pressing the scroll-lock key. This holds the display, and enables the cursor 27arrows for scrolling up and down through the last scrolled out lines. 28 29The keyboard is configurable to suit the individual user and the different 30national layout. 31 32The keys on the keyboard can have any of the following functions: 33 34 Normal key - Enter the ASCII value associated with the key. 35 36 Function key - Enter a string of ASCII values. 37 38 Switch Key - Switch virtual console. 39 40 Modifier Key - Change the meaning of another key. 41 42 43The keyboard is seen as a number of keys numbered from 1 to n. This 44number is often referred to as the "scancode" for a given key. The number 45of the key is transmitted as an 8 bit char with bit 7 as 0 when a key is 46pressed, and the number with bit 7 as 1 when released. This makes it 47possible to make the mapping of the keys fully configurable. 48 49The meaning of every key is programmable via the PIO_KEYMAP ioctl call, that 50takes a structure keymap_t as argument. The layout of this structure is as 51follows: 52.Pp 53.Bd -literal -offset indent 54 struct keymap { 55 u_short n_keys; 56 struct key_t { 57 u_char map[NUM_STATES]; 58 u_char spcl; 59 u_char flgs; 60 } key[NUM_KEYS]; 61 }; 62.Ed 63.Pp 64The field n_keys tells the system how many keydefinitions (scancodes) 65follows. Each scancode is then specified in the key_t substructure. 66 67Each scancode can be translated to any of 8 different values, depending 68on the shift, control, and alt state. These eight possibilities is 69represented by the map array, as shown below: 70 71 alt 72 scan cntrl alt alt cntrl 73 code base shift cntrl shift alt shift cntrl shift 74 map[n] 0 1 2 3 4 5 6 7 75 ---- ------------------------------------------------------ 76 0x1E 'a' 'A' 0x01 0x01 'a' 'A' 0x01 0x01 77 78This is the default mapping for the key labelled 'A' wich normally has 79scancode 0x1E. The eight states is as shown, giving the 'A' key its 80normal behavior. 81The spcl field is used to give the key "special" treatment, and is 82interpreted as follows. 83Each bit correspond to one of the states above. If the bit is 0 the 84key emits the number defined in the corresponding map[] entry. 85If the bit is 1 the key is "special". This means it does not emit 86anything, instead it changes the "state". That means it is a shift, 87control, alt, lock, switch-screen, function-key or no-op key. 88The bitmap is backwards ie. 7 for base, 6 for shift etc. 89 90The flgs field defines if the key should react on caps-lock (1), 91num-lock (2), both (3) or ignore both (0). 92 93The kbdcontrol utility is used to load such a description into/outof 94the kernel at runtime. This make it possible to change the key 95assignments at runtime, or more important to get (GIO_KEYMAP ioctl) 96the exact key meanings from the kernel (fx. used by the X server). 97 98The function keys can be programmed using the PIO_STRMAP ioctl call. 99 100This ioctl takes a argument of the type fkeyarg_t: 101.Bd -literal -offset indent 102 struct fkeyarg { 103 u_short keynum; 104 char keydef[MAXFK]; 105 char flen; 106 }; 107.Ed 108.Pp 109The field keynum defines which function key that is programmed. 110The array keydef should contain the new string to be used (MAXFK long), 111and the length should be entered in flen. 112 113The GIO_STRMAP ioctl call works in a semilar manner, execpt it returns 114the current setting of keynum. 115 116The function keys are numbered like this: 117.Bd -literal -offset indent 118 F1-F12 key 1 - 12 119 Shift F1-F12 key 13 - 24 120 Ctrl F1-F12 key 25 - 36 121 Ctrl+shift F1-F12 key 37 - 48 122 123 Home key 49 124 Up arrow key 50 125 Page Up key 51 126 (keypad) - key 52 127 Left arrow key 53 128 (keypad) 5 key 54 129 Right arrow key 55 130 (keypad) + key 56 131 End key 57 132 Down arrow key 58 133 Page down key 59 134 Insert key 60 135 Delete key 61 136 137 Right window key 62 138 Left window key 63 139 Menu key 64 140.Ed 141 142The kbdcontrol utility also allows changing these values at runtime. 143.Pp 144.Sh AUTHOR 145 S�ren Schmidt (sos@FreeBSD.org) 146