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