keyboard(7) —
NAME
keyboard − video adapter keyboard
DESCRIPTION
The video adapter display (and user’s terminal) is composed of two separate pieces: the keyboard and the display (see display(7)).
The keyboard is used to type data and to send certain control signals to the computer. UNIX system software performs terminal emulation on the console screen and keyboard, and, in doing so, makes use of several particular keys and key combinations. These keys and key combinations have special names that are unique to the UNIX system and may or may not correspond to the keytop labels on your keyboard.
When you press a key, one of the following happens:
− An ASCII value is entered. − The meaning of another key, or keys, is changed. − A string is sent to the computer. − A function is initiated.
When a key is pressed (a keystroke), the keyboard sends a scancode to the computer. This scancode is interpreted by the keyboard driver. The actual code sequence delivered to the terminal input routine (see termio(7)) is defined by a set of internal tables in the driver. These tables can be modified by software (see the discussion of ioctl calls below). In addition, the driver can be instructed not to do translations, delivering the keyboard up/down scan codes directly.
Changing Meanings
The action performed by a key can be changed by using certain keys in combination. For example, SHIFT changes the ASCII values of the alphanumeric keys. Holding down CTRL while pressing another key sends a control code (such as CTRL d, CTRL s, and CTRL q). Holding down ALT also modifies a key’s value. SHIFT, CTRL, and ALT can be used in combination.
Switching Screens
To switch the current screen, hold down ALT SYSREQ (also labelled ALT PRINTSCRN on some systems) and a key that identifies the desired screen. Any active screen may be selected by following ALT SYSREQ with Fn, where Fn is one of the function keys. F1 refers to the first virtual terminal screen, F2 refers to the second virtual terminal screen, etc. ALT SYSREQ h and ALT SYSREQ F8 refer to the main console display (/dev/console), if the console refers to a video adapter. The next active screen can be selected with ALT SYSREQ n, and the previous screen can be selected with ALT SYSREQ p.
The default screen switch enable sequence ( ALT SYSREQ ) is configurable. The SYSREQ table entry can be modified by software (see discussion of ioctl calls below).
Special Keys
The following table shows which keys on a typical console correspond to UNIX System keys. In this table, a hyphen (−) between keys means you must hold down the first key while pressing the second. The mapping between characters that generate signals and the signal actually generated is set with stty(1) and may be changed (see stty(1)).
| Name | Keytop | Action |
| INTR | DEL | Stops current action and returns to the shell. This key is also called the RUB OUT or INTERRUPT key. |
| BACKSPACE | ← | Deletes the first character to the left of the cursor. Note that the “cursor left” key also has a left arrow (←) on its keytop, but you cannot backspace using that key. |
| CTRL-d | CTRL-d | Signals the end of input from the keyboard; also exits current shell. |
| CTRL-h | CTRL-h | Deletes the first character to the left of the cursor. Also called the ERASE key. |
| CTRL-q | CTRL-q | Restarts printing after it has been stopped with CTRL-s. |
| CTRL-s | CTRL-s | Suspends printing on the screen (does not stop the program). |
| CTRL-u | CTRL-u | Deletes all characters on the current line. Also called the KILL key. |
| CTRL-\ | CTRL-\ | Quits current command and creates a core file, if allowed. (Recommended for debugging only.) |
| ESCAPE | ESC | Special code for some programs. For example, changes from insert mode to command mode in the vi(1) text editor. |
| RETURN | (down-left arrow or ENTER) |
Terminates a command line and initiates an action from the shell. |
| Fn | Fn | Function key n. F1-F12 are unshifted, F13-F24 are shifted F1-F12, F25-F36 are CTRL-F1 through F12, and F37-F48 are CTRL-SHIFT-F1 through F12. The next Fn keys (F49-F60) are on the number pad (unshifted): F49 − ‘7’ F55 − ‘6’ F50 − ‘8’ F56 − ‘+’ F51 − ‘9’ F57 − ‘1’ F52 − ‘−’ F58 − ‘2’ F53 − ‘4’ F59 − ‘3’ F54 − ‘5’ F60 − ‘0’ |
Keyboard Map
The keyboard mapping structure is defined in /usr/include/sys/kd.h. Each key can have ten states. The first eight states are:
BASE
SHIFT
CTRL
ALT
CTRL-SHIFT
ALT-SHIFT
ALT-CTRL
ALT-CTRL-SHIFT
The two remaining states are indicated by two special bytes. The first byte is a “special state” byte whose bits indicate whether the key is “special” in one or more of the first eight states. The second byte is one of four codes represented by the characters C, N, B, or O which indicate how the lock keys affect the particular key.
The following table describes the default keyboard mapping. All values, except for special keywords (which are described later), are ASCII character values.
Heading Description
SCAN CODE This column contains the index to the table. Numbers 1 through 83 and 86 through 88 are actual scan codes generated by the keyboard hardware when a key is pressed. The numbers that do not have an entry in the KEY LOCATION column are not used. The remaining numbers are used for keys that generate a sequence of more than one code. There are no table entries for the scan code generated by releasing a key.
KEY LOCATION This column contains the location number for the key on the 101-key keyboard map that precedes the table. Key location 45 (scan code 86) is for the international 102-key keyboard and is not shown (it is located between keys 44 and 46).
BASE This column contains the normal value of a key press.
SHIFT This column contains the value of a key press when the SHIFT key is also being held down.
LOCK This column indicates which lock keys affect that particular key:
− C indicates CAPS-LOCK
− N indicates NUM-LOCK
− B indicates both
− O indicates locking is off
The remaining columns are the values of key presses when combinations of CTRL, ALT, and SHIFT are also held down.
The SRQTAB column entry is included in this table to provide a simple index of the default virtual terminal key selectors to the scan code to which it is assigned. The actual SRQTAB table is a stand-alone table which can be read or written via the KDGKBENT and KDSKBENT ioctl calls.
| ALT | |||||||||||
| SCAN | KEY | CTRL | ALT | ALT | CTRL | ||||||
| CODE | LOCATION | BASE | SHIFT | CTRL | SHIFT | ALT | SHIFT | CTRL | SHIFT | LOCK | SRQTAB |
| 0 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 1 | 110 | esc | esc | esc | esc | esc | esc | esc | esc | O | nop |
| 2 | 2 | ’1’ | ’!’ | ’1’ | ’1’ | escn | escn | nop | nop | O | nop |
| 3 | 3 | ’2’ | ’ | ’ | ’2’ | nul | escn | escn | nop | nop | O |
| 4 | 4 | ’3’ | ’#’ | ’3’ | ’3’ | escn | escn | nop | nop | O | nop |
| 5 | 5 | ’4’ | ’$’ | ’4’ | ’4’ | escn | escn | nop | nop | O | nop |
| 6 | 6 | ’5’ | ’%’ | ’5’ | ’5’ | escn | escn | nop | nop | O | nop |
| 7 | 7 | ’6’ | ’^’ | ’6’ | rs | escn | escn | nop | nop | O | nop |
| 8 | 8 | ’7’ | ’&’ | ’7’ | ’7’ | escn | escn | nop | nop | O | nop |
| 9 | 9 | ’8’ | ’*’ | ’8’ | ’8’ | escn | escn | nop | nop | O | nop |
| 10 | 10 | ’9’ | ’(’ | ’9’ | ’9’ | escn | escn | nop | nop | O | nop |
| 11 | 11 | ’0’ | ’)’ | ’0’ | ’0’ | escn | escn | nop | nop | O | nop |
| 12 | 12 | ’-’ | ’_’ | ’-’ | ns | escn | escn | nop | nop | O | nop |
| 13 | 13 | ’=’ | ’+’ | ’=’ | ’=’ | escn | escn | nop | nop | O | nop |
| 14 | 15 | bs | bs | bs | bs | bs | bs | bs | bs | O | nop |
| 15 | 16 | ht | btab | ht | btab | ht | btab | ht | btab | O | nop |
| 16 | 17 | ’q’ | ’Q’ | dc1 | dc1 | escn | escn | nop | nop | C | nop |
| 17 | 18 | ’w’ | ’W’ | etb | etb | escn | escn | nop | nop | C | nop |
| 18 | 19 | ’e’ | ’E’ | enq | enq | escn | escn | nop | nop | C | nop |
| 19 | 20 | ’r’ | ’R’ | dc2 | dc2 | escn | escn | nop | nop | C | nop |
| 20 | 21 | ’t’ | ’T’ | dc4 | dc4 | escn | escn | nop | nop | C | nop |
| 21 | 22 | ’y’ | ’Y’ | em | em | escn | escn | nop | nop | C | nop |
| 22 | 23 | ’u’ | ’U’ | nak | nak | escn | escn | nop | nop | C | nop |
| 23 | 24 | ’i’ | ’I’ | ht | ht | escn | escn | nop | nop | C | nop |
| 24 | 25 | ’o’ | ’O’ | si | si | escn | escn | nop | nop | C | nop |
| 25 | 26 | ’p’ | ’P’ | dle | dle | escn | escn | nop | nop | C | PREV |
| 26 | 27 | ’[’ | ’{’ | esc | nop | escn | escn | nop | nop | O | nop |
| 27 | 28 | ’]’ | ’}’ | gs | nop | escn | escn | nop | nop | O | nop |
| 28 | 43 | cr | cr | cr | cr | cr | cr | cr | cr | O | nop |
| 29 | 58 | lctrl | lctrl | lctrl | lctrl | lctrl | lctrl | lctrl | lctrl | O | nop |
| 30 | 31 | ’a’ | ’A’ | soh | soh | escn | escn | nop | nop | C | nop |
| 31 | 32 | ’s’ | ’S’ | dc3 | dc3 | escn | escn | nop | nop | C | nop |
| 32 | 33 | ’d’ | ’D’ | eot | eot | escn | escn | nop | nop | C | nop |
| 33 | 34 | ’f’ | ’F’ | ack | ack | escn | escn | nop | nop | C | FNEXT |
| 34 | 35 | ’g’ | ’G’ | bel | bel | escn | escn | nop | nop | C | nop |
| 35 | 36 | ’h’ | ’H’ | bs | bs | escn | escn | nop | nop | C | VT1 |
| 36 | 37 | ’j’ | ’J’ | nl | nl | escn | escn | nop | nop | C | nop |
| 37 | 38 | ’k’ | ’K’ | vt | vt | escn | escn | nop | nop | C | nop |
| 38 | 39 | ’l’ | ’L’ | np | np | escn | escn | nop | nop | C | nop |
| 39 | 40 | ’;’ | ’:’ | ’;’ | ’:’ | escn | escn | nop | nop | O | nop |
| 40 | 41 | ’´’ | ’"’ | ’´’ | ’"’ | escn | escn | nop | nop | O | nop |
| 41 | 1 | ’‘’ | ’~’ | ’‘’ | ’~’ | escn | escn | nop | nop | O | nop |
| 42 | 44 | lshift | lshift | lshift | lshift | lshift | lshift | lshift | lshift | O | nop |
| 43 | 29 | ’\\’ | ’|’ | fs | ’|’ | escn | escn | nop | nop | O | nop |
| ALT | |||||||||||
| SCAN | KEY | CTRL | ALT | ALT | CTRL | ||||||
| CODE | LOCATION | BASE | SHIFT | CTRL | SHIFT | ALT | SHIFT | CTRL | SHIFT | LOCK | SRQTAB |
| 44 | 46 | ’z’ | ’Z’ | sub | sub | escn | escn | nop | nop | C | nop |
| 45 | 47 | ’x’ | ’X’ | can | can | escn | escn | nop | nop | C | nop |
| 46 | 48 | ’c’ | ’C’ | etx | etx | escn | escn | nop | nop | C | nop |
| 47 | 49 | ’v’ | ’V’ | syn | syn | escn | escn | nop | nop | C | nop |
| 48 | 50 | ’b’ | ’B’ | stx | stx | escn | escn | nop | nop | C | nop |
| 49 | 51 | ’n’ | ’N’ | so | so | escn | escn | nop | nop | C | NEXT |
| 50 | 52 | ’m’ | ’M’ | cr | cr | escn | escn | nop | nop | C | nop |
| 51 | 53 | ’,’ | ’<’ | ’,’ | ’<’ | escn | escn | nop | nop | O | nop |
| 52 | 54 | ’.’ | ’>’ | ’.’ | ’>’ | escn | escn | nop | nop | O | nop |
| 53 | 55 | ’/’ | ’?’ | ’/’ | ns | escn | escn | nop | nop | O | nop |
| 54 | 57 | rshift | rshift | rshift | rshift | rshift | rshift | rshift | rshift | O | nop |
| 55 | 100 | ’*’ | ’*’ | ’*’ | ’*’ | escn | escn | nop | nop | O | nop |
| 56 | 60 | lalt | lalt | lalt | lalt | lalt | lalt | lalt | lalt | O | nop |
| 57 | 61 | ’ ’ | ’ ’ | nul | nul | escn | escn | nop | nop | O | nop |
| 58 | 30 | clock | clock | clock | clock | clock | clock | clock | clock | O | nop |
| 59 | 112 | fkey1 | fkey13 | fkey25 | fkey37 | fkey1 | fkey13 | fkey25 | fkey37 | O | VT2 |
| 60 | 113 | fkey2 | fkey14 | fkey26 | fkey38 | fkey2 | fkey14 | fkey26 | fkey38 | O | VT3 |
| 61 | 114 | fkey3 | fkey15 | fkey27 | fkey39 | fkey3 | fkey15 | fkey27 | fkey39 | O | VT4 |
| 62 | 115 | fkey4 | fkey16 | fkey28 | fkey40 | fkey4 | fkey16 | fkey28 | fkey40 | O | VT5 |
| 63 | 116 | fkey5 | fkey17 | fkey29 | fkey41 | fkey5 | fkey17 | fkey29 | fkey41 | O | VT6 |
| 64 | 117 | fkey6 | fkey18 | fkey30 | fkey42 | fkey6 | fkey18 | fkey30 | fkey42 | O | VT7 |
| 65 | 118 | fkey7 | fkey19 | fkey31 | fkey43 | fkey7 | fkey19 | fkey31 | fkey43 | O | VT8 |
| 66 | 119 | fkey8 | fkey20 | fkey32 | fkey44 | fkey8 | fkey20 | fkey32 | fkey44 | O | VT1 |
| 67 | 120 | fkey9 | fkey21 | fkey33 | fkey45 | fkey9 | fkey21 | fkey33 | fkey45 | O | nop |
| 68 | 121 | fkey10 | fkey22 | fkey34 | fkey46 | fkey10 | fkey22 | fkey34 | fkey46 | O | nop |
| 69 | 90 | nlock | nlock | nlock | nlock | nlock | nlock | nlock | nlock | O | nop |
| 70 | 125 | slock | slock | brk | brk | slock | slock | brk | brk | O | nop |
| 71 | 91 | fkey49 | ’7’ | fkey49 | ’7’ | fkey49 | escn | nop | nop | N | nop |
| 72 | 96 | fkey50 | ’8’ | fkey50 | ’8’ | fkey50 | escn | nop | nop | N | nop |
| 73 | 101 | fkey51 | ’9’ | fkey51 | ’9’ | fkey51 | escn | nop | nop | N | nop |
| 74 | 105 | fkey52 | ’-’ | fkey52 | ’-’ | fkey52 | escn | nop | nop | N | nop |
| 75 | 92 | fkey53 | ’4’ | fkey53 | ’4’ | fkey53 | escn | nop | nop | N | nop |
| 76 | 97 | fkey54 | ’5’ | fkey54 | ’5’ | fkey54 | escn | nop | nop | N | nop |
| 77 | 102 | fkey55 | ’6’ | fkey55 | ’6’ | fkey55 | escn | nop | nop | N | nop |
| 78 | 106 | fkey56 | ’+’ | fkey56 | ’+’ | fkey56 | escn | nop | nop | N | nop |
| 79 | 93 | fkey57 | ’1’ | fkey57 | ’1’ | fkey57 | escn | nop | nop | N | nop |
| 80 | 98 | fkey58 | ’2’ | fkey58 | ’2’ | fkey58 | escn | nop | nop | N | nop |
| 81 | 103 | fkey59 | ’3’ | fkey59 | ’3’ | fkey59 | escn | nop | nop | N | nop |
| 82 | 99 | fkey60 | ’0’ | fkey60 | ’0’ | fkey60 | escn | nop | nop | N | nop |
| 83 | 104 | del | ’.’ | del | ’.’ | del | escn | rboot | nop | N | nop |
| 84 | 124 | fkey60 | fkey26 | fkey60 | nop | sysreq | sysreq | sysreq | sysreq | O | nop |
| 85 | 84 | fkey58 | fkey58 | fkey58 | fkey58 | fkey58 | fkey58 | fkey58 | fkey58 | O | nop |
| *86 | 45 | ’<’ | ’>’ | ’<’ | ’>’ | escn | escn | nop | nop | O | nop |
| 87 | 122 | fkey11 | fkey23 | fkey35 | fkey47 | fkey11 | fkey23 | fkey35 | fkey47 | O | nop |
| 88 | 123 | fkey12 | fkey24 | fkey36 | fkey48 | fkey12 | fkey24 | fkey36 | fkey48 | O | nop |
*Applicable only for 102-key keyboard.
| ALT | |||||||||||
| SCAN | KEY | CTRL | ALT | ALT | CTRL | ||||||
| CODE | LOCATION | BASE | SHIFT | CTRL | SHIFT | ALT | SHIFT | CTRL | SHIFT | LOCK | SRQTAB |
| 89 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 90 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 91 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 92 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 93 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 94 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 95 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 96 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 97 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 98 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 99 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 100 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 101 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 102 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 103 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 104 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 105 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 106 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 107 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 108 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 109 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 110 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 111 | 85 | fkey51 | fkey51 | nop | nop | nop | nop | nop | nop | O | nop |
| 112 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 113 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 114 | 62 | ralt | ralt | ralt | ralt | ralt | ralt | ralt | ralt | O | nop |
| 115 | 64 | rctrl | rctrl | rctrl | rctrl | rctrl | rctrl | rctrl | rctrl | O | nop |
| 116 | 108 | cr | cr | cr | cr | cr | cr | cr | cr | O | nop |
| 117 | 95 | ’/’ | ’/’ | nop | nop | escn | escn | nop | nop | O | nop |
| 118 | nop | nop | nop | nop | nop | nop | nop | nop | O | nop | |
| 119 | 126 | brk | brk | brk | brk | brk | brk | brk | brk | O | nop |
| 120 | 83 | fkey50 | fkey50 | nop | nop | nop | nop | nop | nop | O | nop |
| 121 | 76 | del | del | del | del | del | del | del | del | O | nop |
| 122 | 81 | fkey57 | fkey57 | nop | nop | nop | nop | nop | nop | O | nop |
| 123 | 75 | fkey60 | fkey60 | nop | nop | nop | nop | nop | nop | O | nop |
| 124 | 79 | fkey53 | fkey53 | nop | nop | nop | nop | nop | nop | O | nop |
| 125 | 89 | fkey55 | fkey55 | nop | nop | nop | nop | nop | nop | O | nop |
| 126 | 86 | fkey59 | fkey59 | nop | nop | nop | nop | nop | nop | O | nop |
| 127 | 80 | fkey49 | fkey49 | nop | nop | nop | nop | nop | nop | O | nop |
The following table lists the value of each of the special keywords used in the preceding tables. The keywords are only used in the preceding tables for readability. In the actual keyboard map, a special keyword is represented by its value with the corresponding “special state” bit being set.
| Name | Value | Meaning |
| nop | 0 | No operation − no action from keypress |
| lshift | 2 | Left-hand shift |
| rshift | 3 | Right-hand shift |
| clock | 4 | Caps lock |
| nlock | 5 | Numeric lock |
| slock | 6 | Scroll lock |
| alt | 7 | Alt key |
| btab | 8 | Back tab key − generates fixed sequence (ESC[ z) |
| ctrl | 9 | Control key |
| lalt | 10 | Left-hand alt key |
| ralt | 11 | Right-hand alt key |
| lctrl | 12 | Left-hand control key |
| rctrl | 13 | Right-hand control key |
| fkey1 | 27 | Function key #1 |
| . | . | |
| . | . | |
| . | . | |
| fkey96 | 122 | Function key #96 |
| sysreq | 123 | System request |
| brk | 124 | Break key |
| escn | 125 | Generate an ESC N x sequence, where x is the un-alt’ed value of the scan code |
| rboot | 128 | Reboot system |
| debug | 129 | Invoke kernel debugger |
| NEXT | 130 | Switch to next virtual terminal on queue |
| PREV | 131 | Switch to previous virtual terminal on queue |
| FNEXT | 132 | Forced switch to next virtual terminal on queue |
| VT1 | 134 | Switch to virtual terminal #1 |
| . | . | |
| . | . | |
| . | . | |
| VT8 | 141 | Switch to virtual terminal #8 |
The following table lists names and decimal values for ASCII characters in the preceding table. Names are used in place of numeric constants to make it easier to read the scan code table. Only the decimal values are placed in the ioctl buffer. These values are taken from ascii(5).
| Name | Value | Name | Value |
| nul | 0 | dc1 | 17 |
| soh | 1 | dc2 | 18 |
| stx | 2 | dc3 | 19 |
| etx | 3 | dc4 | 20 |
| eot | 4 | nak | 21 |
| enq | 5 | syn | 22 |
| ack | 6 | etb | 23 |
| bel | 7 | can | 24 |
| bs | 8 | em | 25 |
| ht | 9 | sub | 26 |
| nl | 10 | esc | 27 |
| vt | 11 | fs | 28 |
| np | 12 | gs | 29 |
| cr | 13 | rs | 30 |
| so | 14 | ns | 3131 |
| si | 15 | del | 127 |
| dle | 16 |
String Key Mapping
The string mapping table is an array of 512 bytes (typedef strmap_t) containing null-terminated strings that redefine the function keys. The first null-terminated string is assigned to the first function key, the second string is assigned to the second function key, etc.
There is no limit to the length of any particular string as long as the whole table does not exceed 512 bytes, including nulls. To make a string a null, add extra null characters. The following table contains default function key values.
| Default Function Key Values | ||||
| Function | Function | |||
| Key # | Function | Key # | Function | |
| 1 | ESC OP | 32 | ESC OW | |
| 2 | ESC OQ | 33 | ESC OX | |
| 3 | ESC OR | 34 | ESC OY | |
| 4 | ESC OS | 35 | ESC OZ | |
| 5 | ESC OT | 36 | ESC OA | |
| 6 | ESC OU | 37 | ESC Op | |
| 7 | ESC OV | 38 | ESC Oq | |
| 8 | ESC OW | 39 | ESC Or | |
| 9 | ESC OX | 40 | ESC Os | |
| 10 | ESC OY | 41 | ESC Ot | |
| 11 | ESC OZ | 42 | ESC Ou | |
| 12 | ESC OA | 43 | ESC Ov | |
| 13 | ESC Op | 44 | ESC Ow | |
| 14 | ESC Oq | 45 | ESC Ox | |
| 15 | ESC Or | 46 | ESC Oy | |
| 16 | ESC Os | 47 | ESC Oz | |
| 17 | ESC Ot | 48 | ESC Oa | |
| 18 | ESC Ou | 49 | ESC [H | |
| 19 | ESC Ov | 50 | ESC [A | |
| 20 | ESC Ow | 51 | ESC [V | |
| 21 | ESC Ox | 52 | ESC [S | |
| 22 | ESC Oy | 53 | ESC [D | |
| 23 | ESC Oz | 54 | ESC [G | |
| 24 | ESC Oa | 55 | ESC [C | |
| 25 | ESC OP | 56 | ESC [T | |
| 26 | ESC OQ | 57 | ESC [Y | |
| 27 | ESC OR | 58 | ESC [B | |
| 28 | ESC OS | 59 | ESC [U | |
| 29 | ESC OT | 60 | ESC [@ | |
| 30 | ESC OU | 61 | ESC [2 | |
| 31 | ESC OV | |||
Ioctl Calls
KDGKBMODE
This call gets the current keyboard mode. The argument to the call is the address of an unsigned character. The ioctl sets the unsigned char to one of the following values, as defined in /usr/include/sys/kd.h:
#defineK_RAW0x00/* Send raw scan codes */
#defineK_XLATE0x01/* Translate to ASCII */
KDSKBMODE
This call sets the keyboard mode. The argument to the call is either K_RAW or K_XLATE. By using raw mode, the program can see the raw up/down scan codes from the keyboard. In translate mode, the translation tables are used to generate the appropriate character code.
KDGKBTYPE
This call gets the keyboard type. The argument to the call is the address of an unsigned character. The ioctl sets the unsigned char to one of the following values, as defined in /usr/include/sys/kd.h:
#defineKB_840x00/*84 key keyboard*/
#defineKB_1010x01/*101 key keyboard*/
#defineKB_OTHER0x03 /*Other type keyboard*/
KDGKBENT
This call reads one of the entries in the translation tables. The argument to the call is the address of one of the following structures, defined in /usr/include/sys/kd.h, with the first two fields filled in:
struct kbentry {
uncharkb_table;/* Table to use */
uncharkb_index;/* Entry in table */
ushortkb_value;/* Value to get/set */
};
Valid values for the kb_table field are:
#defineK_NORMTAB 0x00 /* Base */
#defineK_SHIFTTAB 0x01 /* Shifted */
#defineK_ALTTAB 0x02 /* Alt */
#defineK_ALTSHIFTTAB 0x03 /* Shifted alt */
#defineK_SRQTAB 0x04 /* Sysreq table */
The ioctl will get the indicated entry from the indicated table and return it in the kb_value field.
The kb_value field is 16 bits, with flags in the high-order 8 bits and the character code in the low-order 8 bits. The values that can be set in the flag byte, as defined in /usr/include/sys/kd.h, are as follows:
/∗ Flag bits ∗/
#defineNUMLCK0x8000/∗ key is affected by num lock ∗/
#defineCAPLCK0x4000/∗ key is affected by caps lock ∗/
#defineCTLKEY0x2000/∗ key is affected by control key ∗/
/∗ Key types ∗/
#defineNORMKEY0x0000/∗ key is a normal key ∗/
#defineSHIFTKEY0x0100/∗ key is a shift key ∗/
#defineBREAKKEY0x0200/∗ key is a break key ∗/
#defineSS2PFX0x0300/∗ prefix key with <ESC> N ∗/
#defineSS3PFX0x0400/∗ prefix key with <ESC> O ∗/
#defineCSIPFX0x0500/∗ prefix key with <ESC> [ ∗/
#defineNOKEY0x0f00/∗ key sends nothing ∗/
KDSKBENT
This call sets an entry in one of the translation tables. It uses the same structure as the KDGKBENT ioctl, but with the third field filled in with the value that should be placed in the translation table. This can be used to partially or completely remap the keyboard.
The kd driver provides support for virtual terminals. Two ioctls are provided for virtual terminal support:
VT_GETSTATE
The VT_GETSTATE ioctl returns global virtual terminal state information. It returns the active virtual terminal in the v_active field, and the number of active virtual terminals and a bit mask of the global state in the vt_state field, where “bit x” is the state of “vt x” (1 indicates that the virtual terminal is open).
VT_SENDSIG
The VT_SENDSIG ioctl specifies a signal (in vt_signal) to be sent to a bit mask of virtual terminals (in vt_state).
The data structure used by the VT_GETSTATE and VT_SENDSIG ioctls is:
struct vt_stat {
ushort v_active; /* active vt */
ushort v_signal; /* signal to send (VT_SENDSIG) */
ushort v_state; /* vt bit mask (VT_SENDSIG and VT_GETSTATE) */
};
and is defined in /usr/include/sys/vt.h.
VT_OPENQRY
The VT_OPENQRY ioctl is used to get the next available virtual terminal. This value is set in the last argument of the ioctl(2) call.
GIO_KEYMAP
This call gets the entire keyboard mapping table from the kernel. The structure of the argument is given in /usr/include/sys/kd.h.
PIO_KEYMAP
This call sets the entire keyboard mapping table. The structure of the argument is given in /usr/include/sys/kd.h.
GIO_STRMAP
This call gets the string key mapping table from the kernel. The structure of the argument is given in /usr/include/sys/kd.h.
PIO_STRMAP
This call sets the string key mapping table. The structure of the argument is given in /usr/include/sys/kd.h.
TIOCKBOF
Extended character codes are disabled. This is the default mode.
TIOCKBON
Allows extended characters to be transmitted to the user program. The extended characters are transmitted as a null byte followed by a second byte containing the character’s extended code. When a true null byte is sent, it is transmitted as two consecutive null bytes.
KDSETRAD
This call allows the application to set the keyboard typematic rate and delay. The default value is 0x20, which sets the keyboard at 30 characters per second with a ½-second start-up delay. For other allowable values, refer to the IBM Technical Reference Manual.
When the keyboard is fully enabled, an 8-bit character code can be obtained by holding down the ALT key and entering the 3-digit decimal value of the character from the numeric keypad. The character is transmitted when the ALT key is released.
Some keyboard characters have special meaning. Under default operations, pressing the DELETE key generates an interrupt signal which is sent to all processes designated with the associated control terminal. When the keyboard is fully enabled, holding down the ALT key and pressing the 8 key on the home keyboard (not on the numeric keypad) returns a null byte followed by 0x7F. This will produce the same effect as the DELETE key (0x7F) unless you have executed the stty(1) command with the −isig option.
KBENABLED
If the keyboard is fully enabled (TIOCKBON), a nonzero value will be returned. If the keyboard is not fully enabled (TIOCKBOF), a value of zero will be returned.
GETFKEY
Obtains the current definition of a function key. The argument to the call is the address of one of the following structures defined in /usr/include/sys/kd.h:
struct fkeyarg {
unsigned intkeynum;
charkeydef [MAXFK]; /*Comes from ioctl.h via comcrt.h*/
charflen;
};
The function key number must be passed in keynum (see arg structure above). The string currently assigned to the key will be returned in keydef, and the length of the string will be returned in flen when the ioctl is performed.
SETFKEY
Assigns a given string to a function key. It uses the same structure as the GETFKEY ioctl. The function key number must be passed in keynum, the string must be passed in keydef, and the length of the string (number of characters) must be passed in flen.
FILES
/dev/console
/dev/vt00-n
/usr/include/sys/kd.h
SEE ALSO
stty(1), ioctl(2), ascii(5), console(7), display(7), termio(7).
ADDED VALUE
This entry, supplied by SunSoft, Inc., contains enhancements to UNIX System V.
\*U — Version 1.0