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