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

	Home			key 49
	Up arrow		key 50
	Page Up			key 51
	(keypad) -		key 52
	Left arrow		key 53
	(keypad) 5              key 54
	Right arrow		key 55
	(keypad) +		key 56
	End			key 57
	Down arrow		key 58
	Page down		key 59
	Insert 			key 60
	Delete			key 61

	Left window		key 62
	Right window		key 63
	Menu			key 64</pre>
</div>
<p class="Pp">The <a class="Xr">kbdcontrol(1)</a> utility also allows changing
    these values at runtime.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp"><span class="An">S&#x00F8;ren Schmidt</span>
    &lt;<a class="Mt" href="mailto:sos@FreeBSD.org">sos@FreeBSD.org</a>&gt;</p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">January 8, 1995</td>
    <td class="foot-os">FreeBSD 15.0</td>
  </tr>
</table>