<!doctype linuxdoc system>

<article>

<title>Keyboard scancodes
<author>Andries Brouwer, <tt/aeb@cwi.nl/
<date>v1.2, 2003-07-25

<abstract>
This note contains some information about PC keyboard scancodes.
</abstract>

<toc>

<sect>Keyboard scancodes<p>
The data from a keyboard comes mainly in the form of scancodes,
produced by key presses or used in the protocol with the computer.
(<ref id="kscancodes" name="Different codes"> are used by the keyboard
firmware internally, and there also exist several
<ref id="kscancodes" name="sets of scancodes">. Here, for the
time being, we only give the default codes - those from translated
scancode set 2.)
Each key press and key release produces between 0 and 6 scancodes.

<sect1>Key release<p>
Below I'll only mention the scancode for key press (`make').
The scancode for key release (`break') is obtained from it
by setting the high order bit (adding 0x80 = 128).
Thus, Esc press produces scancode <bf>01</bf>, Esc release
scancode <bf>81</bf> (hex).
For sequences things are similar: Keypad-/ gives <bf>e0</bf> <bf>35</bf>
when pressed, <bf>e0</bf> <bf>b5</bf> when released. Most keyboards will
repeat the make code (key down code) when the key repeats. Some will also
fake Shift down and Shift up events during the repeat.

The keys PrtSc/SysRq and Pause/Break are special.
The former produces scancode <bf>e0</bf> <bf>2a</bf> <bf>e0</bf> <bf>37</bf>
when no modifier key is pressed simultaneously, <bf>e0</bf> <bf>37</bf>
together with Shift or Ctrl, but <bf>54</bf> together with (left or right) Alt.
(And one gets the expected sequences upon release. But see
<ref id="mtek" name="below">.)
The latter produces scancode sequence
<bf>e1</bf> <bf>1d</bf> <bf>45</bf> <bf>e1</bf> <bf>9d</bf> <bf>c5</bf>
when pressed (without modifier) and nothing at all upon release.
However, together with (left or right) Ctrl, one gets
<bf>e0</bf> <bf>46</bf> <bf>e0</bf> <bf>c6</bf>,
and again nothing at release. It does not repeat.

<sect1>Protocol scancodes<p>
Most scancodes indicate a key press or release.
Some are used in the communication protocol.
<p>
<bf>00</bf> (Keyboard error - see <bf>ff</bf>)
<p>
<bf>aa</bf> (BAT [Basic Assurance Test] OK)
<p>
<bf>ee</bf> (Result of echo command)
<p>
<bf>f1</bf> (Some keyboards, as reply to command <bf>a4</bf>:
Password not installed)
<p>
<bf>fa</bf> (Acknowledge from kbd)
<p>
<bf>fc</bf> (BAT error or Mouse transmit error)
<p>
<bf>fd</bf> (Internal failure)
<p>
<bf>fe</bf> (Keyboard fails to ack, please resend)
<p>
<bf>ff</bf> (Keyboard error)
<newline>
Three common causes for keyboard error are:
(i) several keys pressed simultaneously,
(ii) keyboard buffer overflow,
(iii) parity error on the serial line used by keyboard
and keyboard controller for communication.
The error reported is <bf>ff</bf> in
<ref name="scancode mode" id="kscancodes"> 1,
and <bf>00</bf> in scancode modes 2 and 3.
If translation is on, both <bf>00</bf> and <bf>ff</bf>
are translated as <bf>ff</bf>.
<p>
Usually these codes have the protocol meaning. However,
they also occur as actual scancodes, especially when
prefixed by <bf>e0</bf>.

<sect1>Escape scancodes<p>
The codes <bf>e0</bf> and <bf>e1</bf> introduce scancode sequences,
and are not usually used as isolated scancodes themselves
(but see <ref id="e0_as_key" name="below">).
<p>
(The prefix <bf>e0</bf> was originally used for the grey duplicates
of keys on the original PC/XT keyboard. These days <bf>e0</bf> is
just used to expand code space. The prefix <bf>e1</bf> used for
Pause/Break indicated that this key sends the make/break sequence
at make time, and does nothing upon release.)
<p>
This, and the above, means that the values
<bf>00</bf>, <bf>60</bf>, <bf>61</bf>, <bf>6e</bf>, <bf>71</bf>,
<bf>7a</bf>, <bf>7c</bf>, <bf>7e</bf>, <bf>7f</bf>
are unavailable to signify key presses (on a default keyboard).
Nevertheless they also occur as scancodes, see for example the
<ref id="telerate" name="Telerate"> and
<ref id="safeway23" name="Safeway SW23"> keyboards below.
<p>
Also other prefixes occur, see <ref id="prefix_80" name="below">.

<sect1>Ordinary scancodes<p>
The scancodes in translated scancode set 2 are given in hex.
Between parentheses the keycap on a US keyboard.
The scancodes are given in order, grouped according
to groups of keys that are usually found next to each other.
<p>
<bf>00</bf> is normally an error code
<p>
<bf>01</bf> (Esc)
<p>
<bf>02</bf> (1!), <bf>03</bf> (2@), <bf>04</bf> (3#), <bf>05</bf> (4$),
<bf>06</bf> (5%E), <bf>07</bf> (6^), <bf>08</bf> (7&amp;),
<bf>09</bf> (8*), <bf>0a</bf> (9(), <bf>0b</bf> (0)), <bf>0c</bf> (-_),
<bf>0d</bf> (=+), <bf>0e</bf> (Backspace)
<p>
<bf>0f</bf> (Tab), <bf>10</bf> (Q), <bf>11</bf> (W), <bf>12</bf> (E),
<bf>13</bf> (R), <bf>14</bf> (T), <bf>15</bf> (Y),
<bf>16</bf> (U), <bf>17</bf> (I), <bf>18</bf> (O),
<bf>19</bf> (P), <bf>1a</bf> ([{), <bf>1b</bf> (]})
<p>
<bf>1c</bf> (Enter)
<p>
<bf>1d</bf> (LCtrl)
<p>
<bf>1e</bf> (A), <bf>1f</bf> (S), <bf>20</bf> (D), <bf>21</bf> (F),
<bf>22</bf> (G), <bf>23</bf> (H), <bf>24</bf> (J), <bf>25</bf> (K),
<bf>26</bf> (L), <bf>27</bf> (;:), <bf>28</bf> ('")
<p>
<bf>29</bf> (`&tilde;)
<p>
<bf>2a</bf> (LShift)
<p>
<bf>2b</bf> (\|), on a 102-key keyboard
<p>
<bf>2c</bf> (Z), <bf>2d</bf> (X), <bf>2e</bf> (C), <bf>2f</bf> (V),
<bf>30</bf> (B), <bf>31</bf> (N), <bf>32</bf> (M), <bf>33</bf> (,&lt;),
<bf>34</bf> (.&gt;), <bf>35</bf> (/?), <bf>36</bf> (RShift)
<p>
<bf>37</bf> (Keypad-*) or (*/PrtScn) on a 83/84-key keyboard
<p>
<bf>38</bf> (LAlt), <bf>39</bf> (Space bar),
<p>
<bf>3a</bf> (CapsLock)
<p>
<bf>3b</bf> (F1), <bf>3c</bf> (F2), <bf>3d</bf> (F3), <bf>3e</bf> (F4),
<bf>3f</bf> (F5), <bf>40</bf> (F6), <bf>41</bf> (F7),
<bf>42</bf> (F8), <bf>43</bf> (F9), <bf>44</bf> (F10)
<p>
<bf>45</bf> (NumLock)
<p>
<bf>46</bf> (ScrollLock)
<p>
<bf>47</bf> (Keypad-7/Home), <bf>48</bf> (Keypad-8/Up),
<bf>49</bf> (Keypad-9/PgUp)
<p>
<bf>4a</bf> (Keypad--)
<p>
<bf>4b</bf> (Keypad-4/Left), <bf>4c</bf> (Keypad-5),
<bf>4d</bf> (Keypad-6/Right), <bf>4e</bf> (Keypad-+)
<p>
<bf>4f</bf> (Keypad-1/End), <bf>50</bf> (Keypad-2/Down),
<bf>51</bf> (Keypad-3/PgDn)
<p>
<bf>52</bf> (Keypad-0/Ins), <bf>53</bf> (Keypad-./Del)
<p>
<bf>54</bf> (Alt-SysRq) on a 84+ key keyboard
<p>
<bf>55</bf> is less common; occurs e.g. as F11 on a Cherry G80-0777 keyboard,
as F12 on a Telerate keyboard,
as PF1 on a Focus 9000 keyboard, and as FN on an IBM ThinkPad.
<p>
<bf>56</bf> mostly on non-US keyboards. It is often an unlabelled key
<htmlurl name="to the left" url="laser.jpg">
or <htmlurl name="to the right" url="toshiba.jpg">
of the left Alt key.
<newline>
<figure><eps file="absent"><img src="laser-s.jpg"></figure>
<figure><eps file="absent"><img src="toshiba-s.jpg"></figure>
<p>
<bf>57</bf> (F11), <bf>58</bf> (F12) both on a 101+ key keyboard
<p>
<bf>59</bf>-<bf>5a</bf>-...-<bf>7f</bf> are less common.
Assignment is essentially random.
Scancodes <bf>55</bf>-<bf>59</bf> occur as F11-F15 on the
<ref id="cherry80" name="Cherry G80-0777"> keyboard.
Scancodes <bf>59</bf>-<bf>5c</bf> occur on the
<ref id="RC930" name="RC930"> keyboard.
X calls <bf>5d</bf> `KEY_Begin'.
Scancodes <bf>61</bf>-<bf>64</bf> occur on a
<ref id="telerate" name="Telerate"> keyboard.
Scancodes <bf>55</bf>, <bf>6d</bf>, <bf>6f</bf>, <bf>73</bf>, <bf>74</bf>,
<bf>77</bf>, <bf>78</bf>, <bf>79</bf>, <bf>7a</bf>, <bf>7b</bf>,
<bf>7c</bf>, <bf>7e</bf> occur on the
<ref id="focus" name="Focus 9000"> keyboard.
Scancodes <bf>65</bf>, <bf>67</bf>, <bf>69</bf>, <bf>6b</bf>
occur on a <ref id="armada" name="Compaq Armada"> keyboard.
Scancodes <bf>66</bf>-<bf>68</bf>, <bf>73</bf> occur on the
<ref id="cherry81" name="Cherry G81-3000"> keyboard.
Scancodes <bf>70</bf>, <bf>73</bf>, <bf>79</bf>, <bf>7b</bf>, <bf>7d</bf>
occur on a <ref id="japanese" name="Japanese 86/106 keyboard">.
<p>

<sect1>Escaped scancodes<p>
Apart from the Pause/Break key, that has an escaped sequence starting
with <bf>e1</bf>, the escape used is <bf>e0</bf>. Often, the codes
are chosen in such a way that something meaningful happens when
the receiver just discards the <bf>e0</bf>.
<p>
<bf>e0</bf> <bf>1c</bf> (Keypad Enter) - <bf>1c</bf> (Enter)
<p>
<bf>e0</bf> <bf>1d</bf> (RCtrl) - <bf>1d</bf> (LCtrl)
<p>
<bf>e0</bf> <bf>2a</bf> (fake LShift) - <bf>2a</bf> (LShift)
<p>
<bf>e0</bf> <bf>35</bf> (Keypad-/) - <bf>35</bf> (/?)
<p>
<bf>e0</bf> <bf>36</bf> (fake RShift) - <bf>36</bf> (RShift)
<p>
<bf>e0</bf> <bf>37</bf> (Ctrl-PrtScn) - <bf>37</bf> (*/PrtScn)
<p>
<bf>e0</bf> <bf>38</bf> (RAlt) - <bf>38</bf> (LAlt)
<p>
<bf>e0</bf> <bf>46</bf> (Ctrl-Break) - <bf>46</bf> (ScrollLock)
<p>
<bf>e0</bf> <bf>47</bf> (Grey Home) - <bf>47</bf> (Keypad-7/Home)
<p>
<bf>e0</bf> <bf>48</bf> (Grey Up) - <bf>48</bf> (Keypad-8/UpArrow)
<p>
<bf>e0</bf> <bf>49</bf> (Grey PgUp) - <bf>49</bf> (Keypad-9/PgUp)
<p>
<bf>e0</bf> <bf>4b</bf> (Grey Left) - <bf>4b</bf> (Keypad-4/Left)
<p>
<bf>e0</bf> <bf>4d</bf> (Grey Right) - <bf>4d</bf> (Keypad-6/Right)
<p>
<bf>e0</bf> <bf>4f</bf> (Grey End) - <bf>4f</bf> (Keypad-1/End)
<p>
<bf>e0</bf> <bf>50</bf> (Grey Down) - <bf>50</bf> (Keypad-2/DownArrow)
<p>
<bf>e0</bf> <bf>51</bf> (Grey PgDn) - <bf>51</bf> (Keypad-3/PgDn)
<p>
<bf>e0</bf> <bf>52</bf> (Grey Insert) - <bf>52</bf> (Keypad-0/Ins)
<p>
<bf>e0</bf> <bf>53</bf> (Grey Delete) - <bf>53</bf> (Keypad-./Del)
<p>
These escaped scancodes occur only on 101+ key keyboards.
The <ref id="microsoft" name="Microsoft keyboard"> adds
<p>
<bf>e0</bf> <bf>5b</bf> (LeftWindow)
<p>
<bf>e0</bf> <bf>5c</bf> (RightWindow)
<p>
<bf>e0</bf> <bf>5d</bf> (Menu)
<p>
Other escaped scancodes occur - see below under the individual keyboards.

<sect1>Fake shifts<p>
The ten grey keys Insert, Home, PgUp, Delete, End, PgDn,
Up, Left, Down, Right are supposed to function regardless
of the state of Shift and NumLock keys. But for an old AT keyboard
the keypad keys would produce digits when Numlock was on or Shift
was down. Therefore, in order to fool old programs,
fake scancodes are sent: when LShift is down, and Insert is
pressed, <bf>e0</bf> <bf>aa</bf> <bf>e0</bf> <bf>52</bf> is sent;
upon release of Insert <bf>e0</bf> <bf>d2</bf> <bf>e0</bf> <bf>2a</bf>
is sent. In other words, a fake LShift-up and
fake LShift-down are inserted.

If the Shift key is released earlier than the repeated key,
then a real Shift-up code occurs (without preceding fake Shift-down)
so that a program ignoring <bf>e0</bf> would see one more Shift-up
than Shift-down.

When NumLock is on, no fake Shifts are sent when Shift was down,
but fake Shifts are sent when Shift was not down. Thus,
with Numlock, if Insert is pressed,
<bf>e0</bf> <bf>2a</bf> <bf>e0</bf> <bf>52</bf> is sent
and upon release <bf>e0</bf> <bf>d2</bf> <bf>e0</bf> <bf>aa</bf> is sent.
The keyboard maintains a private NumLock mode, toggled when
NumLock is pressed, and set when the NumLock LED is set.

In the same way, when Shift is down, the Grey-/ key produces
fake Shift-up and fake Shift-down sequences. However, it does
not react to the state of NumLock. The purpose of course is to
fool programs that identify Grey-/ with ordinary /, so that they
don't treat Shift-Grey-/ like Shift-/, i.e., ?.

On a Toshiba notebook, the three Windows keys are treated like
the group of ten keys mentioned, and get fake shifts when
(left or right) Shift is down. They do not react to NumLock.

<sect1>Added non-fake shifts<p>
On my 121-key <ref id="nokia" name="Nokia Data"> keyboard there are
function keys F1, ..., F24, where F1, ..., F12 send the expected codes
<bf>3b</bf>, ..., <bf>58</bf>, and F13, ..., F24 send the same codes
together with the LShift code <bf>2a</bf>.
Thus, F13 gives <bf>2a</bf> <bf>3b</bf> on press,
and <bf>bb</bf> <bf>aa</bf> on release.
Similarly, there are keys with added LCtrl code <bf>1d</bf>.
But there are also keys with added fake shifts <bf>e0 2a</bf>.
<p>
<htmlurl name="Delorie"
url="http://www.delorie.com/djgpp/doc/rbinter/it/06/0.html">
reports that <it>the "Preh Commander AT" keyboard with additional F11-F22 keys
treats F11-F20 as Shift-F1..Shift-F10 and F21/F22 as Ctrl-F1/Ctrl-F2; the
Eagle PC-2 keyboard with F11-F24 keys treats those additional keys
in the same way</it>.

<sect1>Turbo Mode<p>
On some motherboards the LCtrl-LAlt-GreyPlus and LCtrl-LAlt-GreyMinus
switch Turbo mode on/off, respectively. For these, the motherboard
may generate the same scancode sequence when the Turbo button is
pushed: Turbo Switch (High->Low):
<bf>1d</bf> <bf>38</bf> <bf>4a</bf> <bf>ce</bf> <bf>b8</bf> <bf>9d</bf>
and Turbo Switch (Low->High):
<bf>1d</bf> <bf>38</bf> <bf>4e</bf> <bf>ce</bf> <bf>b8</bf> <bf>9d</bf>.
<p>
Other peculiar combinations in this style include
LCtrl-LAlt-LShift-GreyMinus and LCtrl-LAlt-LShift-GreyPlus to turn
system cache off/on.
<p>
If Green PC system power saving mode is enabled in AMIBIOS Setup,
the AMI MegaKey keyboard controller recognizes the combinations
Ctrl-Alt-\ (put the system into immediate power down mode),
Ctrl-Alt-[ (disable the Green PC power savings mode temporarily),
Ctrl-Alt-] (enables the Green PC power down mode).
<p>
Thio Yu Jin &lt;<tt/jin@singmail.com/&gt; complains that on his Toshiba 4010CDS
the Ctrl-Alt-Shift-T key combination brings up the Toshiba user manual.
(04 Mar 1999 - not April 1.)
<p>

<sect1>Power Saving
<label id="power">
<p>
<!-- outdated url="http://www.microsoft.com/HWDEV/specs/PMref/PMinput.htm"-->
<htmlurl url="http://www.microsoft.com/hwdev/tech/input/Scancode.asp"
name="Microsoft"> recommends: "i8042-based keyboards should deploy the
following scan codes for power management buttons, i.e., POWER and SLEEP
buttons:

<table><tabular ca="c|cc">
      | Set-1 make/break                                | Set-2 make/break @@
Power | <bf>e0</bf> <bf>5e</bf> / <bf>e0</bf> <bf>de</bf> |
<bf>e0</bf> <bf>37</bf> / <bf>e0</bf> <bf>f0</bf> <bf>37</bf> @
Sleep | <bf>e0</bf> <bf>5f</bf> / <bf>e0</bf> <bf>df</bf> |
<bf>e0</bf> <bf>3f</bf> / <bf>e0</bf> <bf>f0</bf> <bf>3f</bf> @
Wake  | <bf>e0</bf> <bf>63</bf> / <bf>e0</bf> <bf>e3</bf> |
<bf>e0</bf> <bf>5e</bf> / <bf>e0</bf> <bf>f0</bf> <bf>5e</bf> @
</tabular></table>

The Power, Sleep, and Wake event scan codes are the i8042 equivalents
to the System Power Down, System Sleep, and System Wake Up HID usages".

Many keyboards have Power/Sleep/Wake keys that have to be
activated by a fourth key (unlabeled, or labeled FN): pressing
one of these four keys does not produce any scancodes, but
when the FN key is pressed simultaneously, the Power/Sleep/Wake
keys give the codes listed above.
<p>

<sect1>Initializing special keyboards<p>
Many keyboards have more keys and buttons than the standard ones.
Sometimes these additional keys produce scancode combinations
that were unused before. But on other keyboard such additional
keys do not produce any code at all, until some initializing
action is taken.
<p>
Sometimes that action consists of writing some bytes to keyboard
registers. See, for example, the
<ref id="rapidinit" name="IBM Rapid Access keyboard">, and the
<ref id="omnibookinit" name="Omnibook keyboard">.

<sect1>Manipulating extra LEDs<p>
Some keyboards have additional LEDs, and in a few cases we know
how to manipulate those.

The <ref id="chicony" name="Chicony keyboard"> needs command sequences
<bf>eb</bf> <bf>00</bf> <it>xy</it>, with
<it>xy</it> = <bf>01</bf> for the Moon LED and
<it>xy</it> = <bf>02</bf> for the zzZ LED.

The <ref id="rapidaccess" name="IBM Rapid Access keyboard"> needs
command sequences <bf>eb</bf> <bf>00</bf> <it>xy</it>, with
<it>xy</it> = <bf>04</bf> for the Suspend LED and
<it>xy</it> = <bf>20</bf> for the Mute LED.

<sect>Special keyboards - XT keyboards<p>
<it>First keyboards with an XT interface.
There is no keyboard controller, no commands to the keyboard.
On a modern computer these will usually yield "keyboard error"
or "KB/interface error" or some such, but sometimes they can be
used nevertheless.</it>

The IBM PC (all models) and the IBM XT (models 68, 78, 86, 87, 88,
267, 277) came with this 83-key keyboard.
The IBM AT (models 68, 99, 239, 319) came with an 84-key keyboard.
The IBM XT (models 89, 268, 278, 286) and the IBM AT model 339
came with a 101-key keyboard.

The original IBM 83-key PC/XT keyboard did not have LEDs.
The original IBM 84-key AT keyboard has LEDs, separates the
keypad from the main area, moves the Esc key to the right,
and adds the SysReq key.
The original IBM 101-key keyboard moves the ten function keys
from the left to the top row and adds two more. The Esc key is moved
in front of this row of function keys. The "number" and "cursor"
functions of the keypad are separated. There are duplicate Ctrl and Alt
keys. <!-- There are no LEDs. ? -->

<sect1>XT keyboard<p>
The <htmlurl name="XT keyboard" url="xtkbd.jpg">
has 83 keys, nicely numbered 1-83, that is, with scancodes
<bf>01</bf>-<bf>53</bf>. No escaped scancodes.
<p>
<figure><eps file="absent"><img src="xtkbd-s.jpg"></figure>

<sect1>Victor keyboard<p>
This <htmlurl name="Victor keyboard" url="victor.jpg">
is very similar. The keypad is separated here, and the Esc key
has been moved to the keypad. The frontside of the ScrollLock key
says Break. It resembles an AT keyboard but has only 83 keys,
the SysRq is still missing.
<p>
<figure><eps file="absent"><img src="victor-s.jpg"></figure>

<sect1>Telerate keyboard
<label id="telerate">
<p>
The <htmlurl name="Telerate keyboard" url="telerate.jpg"> was used
for financial applications, as is clear from the keycaps.
This keyboard (in the old XT version, without <bf>e0</bf> prefixes)
has four additional keys, with scancodes <bf>61</bf>,
<bf>62</bf>, <bf>63</bf>, <bf>64</bf>. The F11 and F12 keys have
scancodes <bf>54</bf> and <bf>55</bf> (instead of the common <bf>57</bf>
and <bf>58</bf>). There are two LEDs (for CapsLock and NumLock).
<p>
<figure><eps file="absent"><img src="telerate-s.jpg"></figure>

<sect1>NCR keyboard<p>
Also with an XT interface this <htmlurl name="NCR keyboard" url="ncr.jpg">,
still with ten function keys on the left, but already with a separate
block of keys between the ordinary keys and the numeric keypad.
This middle block has on top five keys
Ctrl (<bf>1d</bf>, same as the Ctrl on the left),
Del (<bf>53</bf>, same as Keypad-Del/.),
PgUp (<bf>49</bf>, same as Keypad-9/PgUp),
End (<bf>4f</bf>, same as Keypad-1/End),
PgDn (<bf>51</bf>, same as Keypad-3/PgDn), and below five cursor keys
(<bf>48</bf>, same as Keypad-8/Up;
<bf>4b</bf>, same as Keypad-4/Left;
<bf>47</bf>, same as Keypad-7/Home;
<bf>4d</bf>, same as Keypad-6/Right;
<bf>50</bf>, same as Keypad-2/Down).
Enter and Keypad-enter are both <bf>1c</bf>.
Below the Enter key PrtScn/* (<bf>37</bf>), and below that again
Ins (<bf>52</bf>, same as Keypad-0/Ins).
CapsLock and NumLock have a built-in LED.
<p>
<figure><eps file="absent"><img src="ncr-s.jpg"></figure>
<p>

<sect1>Cherry G80-0777
<label id="cherry80">
<p>
According to <htmlurl name="FreeKEYB/kbdinfo.html"
url="http://titan.informatik.uni-bonn.de/~frinke/FreeKEYB/kbdinfo.html">
this keyboard has five additional keys with scancodes
<bf>55</bf> (F11), <bf>56</bf> (F12),
<bf>57</bf> (F13), <bf>58</bf> (F14), <bf>59</bf> (F15).
<p>

<sect>Special keyboards - Amstrad/Schneider keyboards<p>
<it>Since IBM had patented their keyboard design,
Amstrad developed an entirely different keyboard.</it>

<sect1>Amstrad/Schneider PC1512<p>
The <htmlurl name="Amstrad keyboard" url="amstrad.jpg">
is entirely incompatible with XT and AT keyboards, and can be used only
on an Amstrad; conversely, no other keyboard will work on an older Amstrad.
This keyboard has a Del key on the keypad, and both Del-> and Del<- keys
above the Enter key. The Del-> key has scancode <bf>70</bf>.
Left of the Enter key a PrtSc/* key.
There is an additional Enter key with scancode <bf>74</bf>.
It is possible to connect a mouse and/or joystick to the keyboard,
and then these devices also yield scancodes:
<bf>77</bf> (joystick button 1), <bf>78</bf> (joystick button 2),
<bf>79</bf> (joystick right), <bf>7a</bf> (joystick left),
<bf>7b</bf> (joystick up), <bf>7c</bf> (joystick down),
<bf>7d</bf> (mouse right), <bf>7e</bf> (mouse left).
<p>
<figure><eps file="absent"><img src="amstrad-s.jpg"></figure>
<p>

<sect>Special keyboards - AT keyboards<p>
<it>The AT keyboard adds a keyboard controller.
The numeric keypad is now separated from the main keyboard.
There is a single new key, with scancode 84 = <bf>54</bf>,
namely SysRq.</it>

The protocol for AT and later keyboards differs from that for
XT keyboards. Some old keyboards have an XT/AT switch on the
backside that selects the appropriate protocol.
Other keyboard autodetect XT or AT mode.

<figure><eps file="absent"><img src="xt-at-switch.jpg"></figure>

<!-- For example, the PC/XT keyboards use a serial protocol with
startbit 1, while the later keyboards use startbit 0 and stopbit 1. -->

The KeyTronic KB101-1 keyboard has four switches of which the first two
indicate the desired behaviour (00 - autodetect, 01 - unused,
10 - PC/XT, 11 - AT). Autodetect does not always work.

<p>
<sect>Special keyboards - MF II keyboards<p>
<it>Next the modern keyboards. (MF stands for MultiFunctional.)
The layout has changed: the function keys now form a top row.
Function keys F11 and F12 were added. The ten keypad digit keys
that served dual purposes (depending on NumLock and Shift)
were duplicated so that digits and cursor movements could be
produced without help from the Shift or Numlock keys.
Also the Alt and Ctrl keys were duplicated.
Prefixes</it> <bf>e0</bf> <it>and</it> <bf>e1</bf> <it>were introduced
to distinguish old and new versions of the same old key.
All modern keyboards follow this scheme, but many add a messy
collection of "internet buttons" and "CD keys".</it>
<p>
Let us group keyboards according to manufacturer.

<sect1>Compaq keyboards<p>

<sect2>Compaq Armada laptop keyboard
<label id="armada">
<p>
Christian Gennerat &lt;<tt/christian.gennerat@vz.cit.alcatel.fr/&gt; writes:
There are 4 extra keys on the Compaq Armada laptops.
The four keys are located over the Esc-F1..F12, and are labelled *1-*4.
Scancodes: <bf>65</bf>, <bf>67</bf>, <bf>69</bf>, <bf>6b</bf>.

<sect2>Compaq Easy Accesss Internet Keyboard<p>
Petr Slansky &lt;<tt/slansky@usa.net/&gt; writes:
<p>
Internet buttons:
<bf>e0</bf> <bf>13</bf> online community button (people icon),
<bf>e0</bf> <bf>14</bf> online Compaq button (Q icon),
<bf>e0</bf> <bf>15</bf> online services button (bulb icon),
<bf>e0</bf> <bf>1e</bf> online e-mail button (envelope icon),
<bf>e0</bf> <bf>21</bf> online Search button (magnifier icon),
<bf>e0</bf> <bf>23</bf> online start button (i icon),
<bf>e0</bf> <bf>32</bf> online commerce button (shopping basket icon),
<p>
<bf>e0</bf> <bf>68</bf> Quick Print button (printer icon),
<bf>e0</bf> <bf>1f</bf> Favorite Application Launch button (racket icon),
<p>
<bf>e0</bf> <bf>5f</bf> Sleep button,
<p>
CD/DVD player buttons:
<bf>e0</bf> <bf>22</bf> Play/Pause,
<bf>e0</bf> <bf>24</bf> Stop,
<bf>e0</bf> <bf>19</bf> Next Track,
<bf>e0</bf> <bf>10</bf> Previous Track,
<bf>e0</bf> <bf>2c</bf> Eject,
<p>
Volume Control buttons:
<bf>e0</bf> <bf>30</bf> Volume increase (+),
<bf>e0</bf> <bf>2e</bf> Volume decrease (-),
<bf>e0</bf> <bf>20</bf> Mute.
<p>
<figure><eps file="absent"><img src="compaq_easy_access.jpg"></figure>
<!-- photograph from
http://www.compaq.com/athome/international/images/tutorials/keyboard.gif
-->

<sect2>Compaq keyboard<p>
A <htmlurl name="Compaq keyboard" url="compaq_unkn.jpg">
(without further type indication) that I have here,
has the usual setup (with Windows keys) plus a top row of eight buttons,
that produce scancodes
<bf>e0</bf> <bf>23</bf>,
<bf>e0</bf> <bf>1f</bf>,
<bf>e0</bf> <bf>1a</bf>,
<bf>e0</bf> <bf>1e</bf>,
<bf>e0</bf> <bf>13</bf>,
<bf>e0</bf> <bf>14</bf>,
<bf>e0</bf> <bf>15</bf>,
<bf>e0</bf> <bf>1b</bf>.

<figure><eps file="absent"><img src="compaq_unkn-s.jpg"></figure>

<sect1>IBM keyboards<p>
<sect2>IBM Rapid Access keyboard<p>
<label id="rapidaccess">
(Information from Dennis Bjorklund &lt;<tt/dennisb@cs.chalmers.se/&gt;
and others.)
<p>
The IBM Rapid Access keyboard has 14 extra buttons and two more leds
than a normal PC keyboard. By default, these buttons do not generate
any scancodes. To activate them one has to send the sequence
<bf>ea</bf> <bf>71</bf> to the keyboard.
Once that is done the extra keys generate normal e0xx sequences.
To turn off the extra keys you send <bf>ea</bf> <bf>70</bf>.

These 14 keys send the following scancodes (when activated):
<p>
<bf>e0</bf> <bf>25</bf> (Suspend),
<bf>e0</bf> <bf>26</bf> (Help),
<bf>e0</bf> <bf>32</bf> (Prg 1),
<bf>e0</bf> <bf>17</bf> (Prg 2),
<bf>e0</bf> <bf>30</bf> (Prg 3),
<bf>e0</bf> <bf>2e</bf> (Prg 4),
<bf>e0</bf> <bf>19</bf> (Play CD),
<bf>e0</bf> <bf>24</bf> (CD Stop),
<bf>e0</bf> <bf>22</bf> (CD Pause),
<bf>e0</bf> <bf>1e</bf> (Vol -),
<bf>e0</bf> <bf>20</bf> (Vol +),
<bf>e0</bf> <bf>23</bf> (Prev song),
<bf>e0</bf> <bf>21</bf> (Next song),
<bf>e0</bf> <bf>12</bf> (Mute).
<p>

The Suspend and Mute buttons have extra LEDs on them.
Sending the sequence <bf>eb</bf> <bf>00</bf> <bf>ff</bf> to the keyboard
makes all five LEDs lit up for a moment.
The sequence <bf>eb</bf> <bf>00</bf> <bf>04</bf> lights the Suspend LED
(behind a waning moon).
The sequence <bf>eb</bf> <bf>00</bf> <bf>20</bf> makes the Mute LED blink.
<!-- The purpose of bit 40 is unclear; it switches the Suspend LED off,
but does not stop the Mute LED. -->
The sequence <bf>eb</bf> <bf>00</bf> <bf>80</bf> locks the keyboard;
if the Mute LED was blinking it now is lit permanently.
Sending <bf>eb</bf> <bf>00</bf> <bf>ff</bf> unlocks the keyboard again.

<p>
<label id="rapidinit">
Dennis Bjorklund writes:
<it>Here is the hack I use to send commands to the keyboard. After you have
compiled it you can do things like</it> <tt>send_to_keyboard ea 71</tt>,
<it>but don't run two of these at the exact same moment, and don't send
strange codes because the keyboard might lock up.</it>

<it>My computer runs this at every startup. After that the extra buttons on
the rapid access work just fine in XFree86.</it>
<tscreen><verb>
/* gcc -O2 -s -Wall -osend_to_keyboard main.c */
#include <stdlib.h>
#include <unistd.h>
#include <sys/io.h>

int main(int argc, char *argv[]) {
  int i;

  ioperm(0x60, 3, 1);

  for (i = 1; i < argc; i++) {
    int x = strtol(argv[i], 0, 16);

    usleep(300);
    outb(x, 0x60);
  }

  return 0;
}
</verb></tscreen>

<figure><eps file="absent"><img src="ibm_rapid_access.jpg"></figure>
<!-- photograph courtesy of Tom Covo -->

<sect2>IBM Rapid Access II keyboard<p>
<p>
<!-- report by John Elliott &lt;<tt/jce@seasip.demon.co.uk/&gt; and others. -->

This keyboard has a top row of seven color-coded buttons.
On the upper right a "wheel" composite button with six parts.
Below it a blue button ("mute").
Finally, the usual block with four arrow keys has been enlarged
by two more keys ("page left" and "page right").

Keys:
<p>
<bf>e0</bf> <bf>25</bf> (Green, "Internet"),
<bf>e0</bf> <bf>26</bf> (Blue, "Internet shopping"),
<bf>e0</bf> <bf>32</bf> (Yellow, "IBM Web support"),
<bf>e0</bf> <bf>17</bf> (Purple),
<bf>e0</bf> <bf>30</bf> (Red),
<bf>e0</bf> <bf>2e</bf> (Cyan, "Help"),
<bf>e0</bf> <bf>5f</bf> (White, "Standby" - has a LED),
<bf>e0</bf> <bf>20</bf> (CD stop),
<bf>e0</bf> <bf>22</bf> (CD play),
<bf>e0</bf> <bf>24</bf> (CD back),
<bf>e0</bf> <bf>12</bf> (CD fwd),
<bf>e0</bf> <bf>21</bf> (Volume D),
<bf>e0</bf> <bf>23</bf> (Volume U),
<bf>e0</bf> <bf>1e</bf> (Mute - no LED).
<p>

The "back" ("page left") and "forward" ("page right") keys
generate ALT+left and ALT+right respectively:
<bf>38</bf> <bf>e0</bf> <bf>4b</bf> (release sequence
<bf>b8</bf> <bf>e0</bf> <bf>cb</bf>) and
<bf>38</bf> <bf>e0</bf> <bf>4d</bf>.

<figure><eps file="absent"><img src="ibm_rapid_access_II.jpg"></figure>

<sect2>IBM ThinkPad<p>
George Staikos &lt;<tt/staikos@0wned.org/&gt; writes:
<p><it>
I have an IBM ThinkPad i1460. It has the IBM EasyLaunch&lt;tm&gt; keys.
These are four multicoloured keys up at the top of the keyboard
for "Home Page", "Search", "Shop", "Mail".  They dont' seem to create
any keyboard events at all.  The keyboard interrupt doesn't trigger,
<tt>showkeys</tt> doesn't see them do anything, and in DOS, a simple
sequence of BIOS calls doesn't see them either.
Also, being a laptop, it has an FN key.  This key generates <bf>55</bf>.
</it>

<sect1>Logitech keyboards<p>
<sect2>Logitech Internet keyboard<p>
Jonathan DeBoer &lt;<tt/deboer@ugrad.cs.ualberta.ca/&gt; reports:
This keyboard has 18 unusual keys.
<p>
<bf>e0</bf> <bf>7a</bf> (WWW),
<bf>e0</bf> <bf>32</bf> (History),
<bf>e0</bf> <bf>21</bf> (Open URL),
<bf>e0</bf> <bf>23</bf> (Home),
<bf>38</bf> <bf>2a</bf> <bf>0f</bf> <bf>8f</bf> (key press)
<bf>8f</bf> <bf>b8</bf> <bf>aa</bf> (key release) (Send To Back) -
this sequence simulates Alt+Shift+Tab, but contains two Tab releases,
<bf>e0</bf> <bf>17</bf> (Print),
<bf>e0</bf> <bf>10</bf> (Back),
<bf>e0</bf> <bf>22</bf> (Forward),
<bf>e0</bf> <bf>24</bf> (Stop),
<bf>e0</bf> <bf>19</bf> (Refresh),
<bf>e0</bf> <bf>1e</bf> (Search),
<bf>e0</bf> <bf>12</bf> (Find),
<bf>e0</bf> <bf>26</bf> (Add Favourite),
<bf>e0</bf> <bf>18</bf> (Open Favourites),
<bf>e0</bf> <bf>20</bf> (Hot Links),
<bf>e0</bf> <bf>30</bf> (Scroll Up),
<bf>e0</bf> <bf>2e</bf> (Scroll Down),
<bf>e0</bf> <bf>25</bf> (Logitech).
<p>

Ryan Lortie &lt;<tt/desertangel@globalserve.net/&gt; writes:
The "Logitech" key is used as a modifier.
In windows, Logitech-Keypad+ increases volume, Logitech-Keypad- decreases.
There is a conjoined dual-button key for "scroll".
You press the top part to scroll up, the bottom to scroll down.

<sect2>Logitech Cordless Desktop Pro keyboard<p>
Nick Rusnov &lt;<tt/nick@grawk.net/&gt; reports:
<p>
The special buttons on a Logitech Cordless Desktop Pro keyboard
produce the following scancodes:
<p>
<bf>e0</bf> <bf>5f</bf> (Moon (sleep)),
<bf>e0</bf> <bf>32</bf> (Homepage),
<bf>e0</bf> <bf>6c</bf> (Mail),
<bf>e0</bf> <bf>65</bf> (Search),
<bf>e0</bf> <bf>66</bf> (runningguuy),
<bf>e0</bf> <bf>20</bf> (Mute),
<bf>e0</bf> <bf>2e</bf> (VolDown),
<bf>e0</bf> <bf>30</bf> (VolUp),
<bf>e0</bf> <bf>22</bf> (Play/Pause),
<bf>e0</bf> <bf>24</bf> (Stop),
<bf>e0</bf> <bf>10</bf> (Rewind),
<bf>e0</bf> <bf>19</bf> (ff),
<bf>e0</bf> <bf>21</bf> (Logitech).

<sect2>Logitech Access keyboard<p>
Denis Kosygin &lt;<tt/kosygin@math.princeton.edu/&gt; reports:
<p>
In addition to usual 104 keys in the usual PC layout this keyboard
has 11 extra keys.  Ten of them produce the following escape scancodes:
<bf>e0</bf> <bf>5f</bf> (User (moon)),
<bf>e0</bf> <bf>6c</bf> (E-mail),
<bf>e0</bf> <bf>11</bf> (Messenger/SMS),
<bf>e0</bf> <bf>12</bf> (Webcam),
<bf>e0</bf> <bf>20</bf> (Mute (crossed speaker)),
<bf>e0</bf> <bf>30</bf> (VolUp (triangle up with + sign in it)),
<bf>e0</bf> <bf>2e</bf> (VolDown (triangle down with - sign in it)),
<bf>e0</bf> <bf>6d</bf> (Media),
<bf>e0</bf> <bf>32</bf> (My Home),
<bf>e0</bf> <bf>65</bf> (Search).
<p>
The eleventh key (with keycap "F lock") is a switch between two sets
of scancodes for function keys F1-F12.  When "F lock" is pressed, then
F1-F12 act as function keys and produce usual keyscans for these keys.  
When "F lock" is depressed, F1-F12 generate the following keyscans:
<p>
<bf>e0</bf> <bf>3b</bf> (new [F1]),
<bf>e0</bf> <bf>3c</bf> (reply [F2]),
<bf>e0</bf> <bf>3d</bf> (forward [F3]),
<bf>e0</bf> <bf>3e</bf> (send [F4]),
<bf>e0</bf> <bf>10</bf> (rewind [F5]),
<bf>e0</bf> <bf>19</bf> (fast forward [F6]),
<bf>e0</bf> <bf>22</bf> (play/pause [F7]),
<bf>e0</bf> <bf>24</bf> (stop [F8]),
<bf>e0</bf> <bf>43</bf> (my com [F9]),
<bf>e0</bf> <bf>44</bf> (my doc [F10]),
<bf>e0</bf> <bf>57</bf> (my pic [F11]),
<bf>e0</bf> <bf>58</bf> (my music [F12]).
<p>
<figure><eps file="absent"><img src="logitech-access.jpg"></figure>
<p>

<sect1>Microsoft keyboards<p>
<sect2>Microsoft Natural keyboard
<label id="microsoft">
<p>
This keyboard has three additional keys, with escaped scancodes
<bf>e0</bf> <bf>5b</bf> (LeftWindow),
<bf>e0</bf> <bf>5c</bf> (RightWindow),
<bf>e0</bf> <bf>5d</bf> (Menu).
The kscancodes (see <ref id="kscancodes" name="below">)
are <bf>e0</bf> <bf>1f</bf>, <bf>e0</bf> <bf>27</bf> and
<bf>e0</bf> <bf>2f</bf>, respectively.
The USB key codes are usage page 0x07, usage index 227, 231, 101
(decimal), respectively.
Microsoft <htmlurl name="describes"
url="http://www.microsoft.com/hwdev/download/desinit/scancode.zip">
the intended use in detail. Both Windows keys are intended to be
used as modifier keys, like both shift and control and alt keys.
The Menu key may be modified by shift etc.

<sect2>Microsoft Internet keyboard<p>
In addition to the three extra keys on the Microsoft Natural keyboard,
this keyboard has ten keys, with escaped scancodes
<bf>e0</bf> <bf>21</bf> (Calculator),
<bf>e0</bf> <bf>32</bf> (Web/Home),
<bf>e0</bf> <bf>5f</bf> (Sleep),
<bf>e0</bf> <bf>65</bf> (Search),
<bf>e0</bf> <bf>66</bf> (Favorites),
<bf>e0</bf> <bf>68</bf> (Stop),
<bf>e0</bf> <bf>69</bf> (Forward),
<bf>e0</bf> <bf>6a</bf> (Back),
<bf>e0</bf> <bf>6b</bf> (My Computer),
<bf>e0</bf> <bf>6c</bf> (Mail).
The kscancodes (see <ref id="kscancodes" name="below">) are
<bf>e0</bf> <bf>2b</bf>, <bf>e0</bf> <bf>3a</bf>,
<bf>e0</bf> <bf>3f</bf>, <bf>e0</bf> <bf>10</bf>,
<bf>e0</bf> <bf>18</bf>, <bf>e0</bf> <bf>28</bf>,
<bf>e0</bf> <bf>30</bf>, <bf>e0</bf> <bf>38</bf>,
<bf>e0</bf> <bf>40</bf>, <bf>e0</bf> <bf>48</bf>,
respectively.

<sect2>Microsoft Natural keyboard pro<p>
Marco Melgazzi &lt;<tt/marco@techie.com/&gt; reports:
The Microsoft Natural keyboard pro has 19 additional keys,
with escaped scancodes
<bf>e0</bf> <bf>6a</bf> (Back),
<bf>e0</bf> <bf>69</bf> (Forward),
<bf>e0</bf> <bf>68</bf> (Stop),
<bf>e0</bf> <bf>67</bf> (Refresh),
<bf>e0</bf> <bf>65</bf> (Search),
<bf>e0</bf> <bf>66</bf> (Favorites),
<bf>e0</bf> <bf>32</bf> (Web/Home),
<bf>e0</bf> <bf>6c</bf> (Mail),
<bf>e0</bf> <bf>20</bf> (Mute),
<bf>e0</bf> <bf>2e</bf> (Volume -),
<bf>e0</bf> <bf>30</bf> (Volume +),
<bf>e0</bf> <bf>22</bf> (Play/Pause),
<bf>e0</bf> <bf>24</bf> (Stop),
<bf>e0</bf> <bf>10</bf> (Prev Track),
<bf>e0</bf> <bf>19</bf> (Next Track),
<bf>e0</bf> <bf>6d</bf> (Media),
<bf>e0</bf> <bf>6b</bf> (My Computer),
<bf>e0</bf> <bf>21</bf> (Calculator),
<bf>e0</bf> <bf>5f</bf> (Sleep).
(That is, we have the ten extra keys of the Microsoft Internet keyboard,
with the same scancodes, and also Refresh, Mute, Volume -, Volume +,
Play/Pause, Stop, Prev Track, Next Track, Media.)

<sect2>Microsoft Natural Multimedia Keyboard<p>
Jeremy Brand &lt;<tt/jeremy@nirvani.net/&gt; reports:
The Microsoft Natural Multimedia Keyboard has 17 additional keys.
Scancodes are
<p>
? (My Documents),
<bf>e0</bf> <bf>64</bf> (My Pictures),
<bf>e0</bf> <bf>3c</bf> (My Music),
<bf>e0</bf> <bf>20</bf> (Mute),
<bf>e0</bf> <bf>22</bf> (Play/Pause),
<bf>e0</bf> <bf>24</bf> (Stop),
<bf>e0</bf> <bf>30</bf> (Volume +),
<bf>e0</bf> <bf>2e</bf> (Volume -),
<bf>e0</bf> <bf>10</bf> (|<<),
<bf>e0</bf> <bf>19</bf> (>>|),
<bf>e0</bf> <bf>6d</bf> (Media),
<bf>e0</bf> <bf>6c</bf> (Mail),
<bf>e0</bf> <bf>32</bf> (Web/Home),
<bf>e0</bf> <bf>05</bf> (Messenger),
<bf>e0</bf> <bf>21</bf> (Calculator),
<bf>e0</bf> <bf>16</bf> (Log Off),
<bf>e0</bf> <bf>5f</bf> (Sleep).
<p>
Moreover, the function keys are dual purpose.
There is a "function lock" key.
By default the function keys are not function keys, they are
"Help", "Undo", etc.  You have to press the function lock key
and then the function keys act like the usual function keys.
In the default state the scancodes are
<p>
<bf>e0</bf> <bf>3b</bf> (Help) on F1 key,
<bf>e0</bf> <bf>08</bf> (Undo) on F2 key,
<bf>e0</bf> <bf>07</bf> (Redo) on F3 key,
? (New) on F4 key,
? (Open) on F5 key,
? (Close) on F6 key,
? (Replay) on F7 key,
<bf>e0</bf> <bf>42</bf> (Fwd) on F8 key,
<bf>e0</bf> <bf>43</bf> (Send) on F9 key,
<bf>e0</bf> <bf>23</bf> (Spell) on F10 key,
<bf>e0</bf> <bf>57</bf> (Save) on F11 key,
<bf>e0</bf> <bf>58</bf> (Print) on F12 key.
<p>

<sect2>Microsoft Office keyboard
<label id="msoffice">
<p>
Christian Hammond <htmlurl name="reports"
url="http://www.chipx86.com/linuxstuff/officekb/wheel.php">
about the keyboard Scroll Wheel:
<it>The following is my interpretation of the results of</it>
<tt>showkey -s</tt>. <it>I had read that the wheel has 3 speeds,
normal, fast, and faster. However, my results show 4.</it>
<p>
Scroll Up: Normal <bf>e0</bf> <bf>0b</bf>,
Fast <bf>e0</bf> <bf>11</bf>,
Faster <bf>e0</bf> <bf>12</bf>,
Fastest <bf>e0</bf> <bf>1f</bf>.
<p>
Scroll Down: Normal <bf>e0</bf> <bf>8b</bf>,
Fast <bf>e0</bf> <bf>91</bf>,
Faster <bf>e0</bf> <bf>92</bf>,
Fastest <bf>e0</bf> <bf>9f</bf>.
<p>
Wouter van Wijk &lt;<tt/woutervanwijk@netscape.net/&gt; reported the scancodes
given below.
<p>
On the left touchpad above the scroll wheel:
<bf>e0</bf> <bf>6a</bf> (Back),
<bf>e0</bf> <bf>69</bf> (Forward).
On the left touchpad below the scroll wheel:
<bf>e0</bf> <bf>17</bf> (Cut),
<bf>e0</bf> <bf>18</bf> (Copy),
<bf>e0</bf> <bf>0a</bf> (Paste),
<bf>e0</bf> <bf>09</bf> (Application Left),
<bf>e0</bf> <bf>1e</bf> (Application Right),
<p>
Buttons on the top row:
No scancode (F Lock),
<bf>e0</bf> <bf>13</bf> (Word),
<bf>e0</bf> <bf>14</bf> (Excel),
<bf>e0</bf> <bf>32</bf> (Web/Home),
<bf>e0</bf> <bf>6c</bf> (Mail),
<bf>e0</bf> <bf>15</bf> (Calendar),
<bf>e0</bf> <bf>05</bf> (Files),
<bf>e0</bf> <bf>21</bf> (Calculator),
<bf>e0</bf> <bf>20</bf> (Mute),
<bf>e0</bf> <bf>2e</bf> (Volume -),
<bf>e0</bf> <bf>30</bf> (Volume +),
<bf>e0</bf> <bf>16</bf> (Log Off),
<bf>e0</bf> <bf>5f</bf> (Sleep).
This is the expected code for Sleep. However, there do not seem to be
Power and WakeUp keys.
<p>
The twelve function keys can be in two states. In the default state
they produce the (new) codes below. The FLock toggle switches them
back to good old function key state.
<bf>e0</bf> <bf>3b</bf> (Help [F1]),
<bf>e0</bf> <bf>3c</bf> (Office Home [F2]),
<bf>e0</bf> <bf>3d</bf> (Task Pane [F3]),
<bf>e0</bf> <bf>3e</bf> (New [F4]),
<bf>e0</bf> <bf>3f</bf> (Open [F5]),
<bf>e0</bf> <bf>40</bf> (Close [F6]),
<bf>e0</bf> <bf>41</bf> (Reply [F7]),
<bf>e0</bf> <bf>42</bf> (Fwd [F8]),
<bf>e0</bf> <bf>43</bf> (Send [F9]),
<bf>e0</bf> <bf>23</bf> (Spell [F10]),
<bf>e0</bf> <bf>57</bf> (Save [F11]),
<bf>e0</bf> <bf>58</bf> (Print [F12]).
Note that each of these codes is just the <bf>e0</bf> variation
of the ordinary function key code, except for that for Spell [F10].
When the FLock light is off (default) the <bf>e0</bf>-version
is activated.
<p>
Above the 5-key block with Insert, Home, Delete, PgUp, PgDown:
<bf>e0</bf> <bf>08</bf> (Undo),
<bf>e0</bf> <bf>07</bf> (Redo).
<p>
Above the number pad:
<bf>59</bf> (=),
<bf>e0</bf> <bf>4c</bf> (( [PrintScreen]),
<bf>e0</bf> <bf>64</bf> () [ScrollLock]),
<bf>0e</bf> (Backspace),
<bf>0f</bf> (Tab).
These are the usual codes for Backspace and Tab but new codes
for (, ), =. PrintScreen and ScrollLock have the usual codes.
<p>
<figure><eps file="absent"><img src="ms_office.jpg"></figure>
See the <htmlurl name="Microsoft ad"
url="http://www.microsoft.com/hardware/keyboard/ok_info.asp">.

<sect1>Safeway keyboards<p>

<sect2>Safeway SW10 keyboard<p>
The Safeway SW10 keyboard has the usual keys, including the three
Windows keys, and including Power, Sleep, Wake keys
(below Delete, End, PageDown) that do not produce scancodes
unless the Fn key (above Keypad-Minus) is pressed simultaneously.
This Fn key is used together with 11 keys: F1-F7, F11, Power, Sleep, Wake.
Fn-F11 disables the keyboard and another Fn-F11 enables it again.
Fn-F1/F2/F3/F4/F5/F6/F7 sets the repeat rate
(on my keyboard I measured 2.0/4.0/6.7/12/26/32/32 chars/sec respectively).

<sect2>Safeway SW23 keyboard
<label id="safeway23">
<p>
The Safeway SW23 keyboard has 132 keys: the usual 104 keys
(101 plus three Windows keys), five more keys called Turbo
(below Enter, right of RShift), and Power, Sleep, Wake
(below Delete, End, PageDown), and Ez (above Keypad-Minus),
and 23 buttons in two rows above the row of function keys.
By default, the five extra keys do not produce scancodes.
(The Ez is a mode toggle. The Turbo key is used to enable
the Power, Sleep, Wake keys.)
<p>
First row of buttons: three Volume buttons:
<bf>e0</bf> <bf>58</bf> (Mute),
<bf>e0</bf> <bf>5a</bf> (Vol -),
<bf>e0</bf> <bf>70</bf> (Vol +),
five CD Player buttons:
<bf>e0</bf> <bf>59</bf> (Prev),
<bf>e0</bf> <bf>42</bf> (Play),
<bf>e0</bf> <bf>69</bf> (Next),
<bf>e0</bf> <bf>64</bf> (Stop),
<bf>e0</bf> <bf>71</bf> (Eject),
two Recorder buttons:
<bf>e0</bf> <bf>40</bf> (Rew/Play),
<bf>e0</bf> <bf>29</bf> (Rec/Stop).
<p>
Second row of buttons:
<bf>e0</bf> <bf>23</bf> (Sleep),
<bf>e0</bf> <bf>7d</bf> (Cut),
<bf>e0</bf> <bf>7e</bf> (Copy),
<bf>e0</bf> <bf>7f</bf> (Paste),
<bf>e0</bf> <bf>20</bf> (Rotate),
<bf>e0</bf> <bf>43</bf> (Close),
<bf>e0</bf> <bf>30</bf> (My Doc),
<bf>e0</bf> <bf>44</bf> (DOS),
<bf>e0</bf> <bf>79</bf> (Game),
<bf>e0</bf> <bf>77</bf> (WWW),
<bf>e0</bf> <bf>6e</bf> (Calc),
<bf>e0</bf> <bf>3e</bf> (X'fer),
<bf>e0</bf> <bf>6a</bf> (Menu/?).
<p>
The Ez key does not produce scancodes, but toggles a
M/Mode LED, the fourth next to the Num, Caps, Scroll LEDs.
When that LED is set, the 17 keypad keys give different
scancodes:
<bf>e0</bf> <bf>3c</bf> (N/Lock),
<bf>e0</bf> <bf>7b</bf> (/),
<bf>e0</bf> <bf>22</bf> (*),
<bf>e0</bf> <bf>61</bf> (-),
<bf>e0</bf> <bf>0f</bf> (7),
<bf>e0</bf> <bf>21</bf> (8),
<bf>e0</bf> <bf>6b</bf> (9),
<bf>e0</bf> <bf>3d</bf> (+),
<bf>e0</bf> <bf>04</bf> (4),
<bf>e0</bf> <bf>62</bf> (5),
<bf>e0</bf> <bf>39</bf> (6),
<bf>e0</bf> <bf>10</bf> (1),
<bf>e0</bf> <bf>24</bf> (2),
<bf>e0</bf> <bf>05</bf> (3),
<bf>e0</bf> <bf>02</bf> (0),
<bf>e0</bf> <bf>41</bf> (.),
<bf>e0</bf> <bf>3f</bf> (Enter).
<p>
The Turbo key does not produce scancodes, and neither do
Power, Sleep, Wake. However, when Turbo is pressed simultaneously,
the Power, Sleep, Wake keys yield <bf>e0</bf> <bf>5e</bf>,
<bf>e0</bf> <bf>5f</bf>, <bf>e0</bf> <bf>63</bf> as
<ref id="power" name="they should">.
<p>
In untranslated scancode mode 3, the multimedia and power keys
do not yield any code. In untranslated scancode mode 1 they
yield the same code as in untranslated scancode mode 2.
(This is a design bug: untranslated scancode mode 1 should be the same
as translated scancode mode 2 (see <ref id="kscancodes" name="below">),
and this is true for the ordinary keys, but fails here for the
"multimedia" keys. For example, the keys End and Keypad-Minus
(in M/Mode) yield the same <bf>e0</bf> <bf>4f</bf> in
untranslated scancode mode 1.)
<p>
Note that some "protocol keycodes" occur here with <bf>e0</bf> prefix.
Indeed, we see <bf>e1</bf>, <bf>ee</bf>, <bf>f1</bf>, <bf>fe</bf>, <bf>ff</bf>
in the key up sequence for the multimedia keys Keypad-Minus
(<bf>e0</bf> <bf>e1</bf>), Calc (<bf>e0</bf> <bf>ee</bf>),
Eject (<bf>e0</bf> <bf>f1</bf>), Copy (<bf>e0</bf> <bf>fe</bf>),
Paste (<bf>e0</bf> <bf>ff</bf>).

<sect1>Nokia keyboard
<label id="nokia">
<p>
This 121-key <htmlurl name="Nokia keyboard" url="nokia.jpg">
has ten function keys on the left and twenty-four on
the two top rows. On the right a block with cursor keys
and a block with numeric keys. There are three LEDs.
The keys have brown markings, and sometimes also blue ones.
Where both occur, the blue markings describe the usual PC keytops.
<p>
Roughly speaking, the scancodes are as expected.
The <htmlurl name="function keys" url="nokia-top.jpg"> F1-F10,F11,F12
have scan codes <bf>3b</bf>-<bf>44</bf>, <bf>57</bf>, <bf>58</bf> as usual.
The keys on the upper row, labeled F13-F24, yield the same codes as
shifted F1-F12. E.g., F13 gives <bf>2a</bf> <bf>3b</bf> on press,
and <bf>bb</bf> <bf>aa</bf> on release.
The function keys F4,F11,F13-F19,F21,F24 have front labels
CrSel, AltCr, Red, Pink, Green, Yellow, Blue, Turq, White,
Col, USM.
<p>
The <htmlurl name="ten keys on the left" url="nokia-left.jpg">
have the following scancodes.
First column of five:
<bf>01</bf> (Attn/Esc/NxtTsk), as expected for Esc;
<bf>1d 3b</bf> (Quit/Reset), as expected for Ctrl F1;
<bf>1d 3c</bf> (ExSel), as expected for Ctrl F2;
<bf>1d 3d</bf> (Ident/Print), as expected for Ctrl F3;
<bf>1d 3e</bf> (Help/EnlW), as expected for Ctrl F4.
For these last four keys (and the ChgSc/WSCtrl below) the code
becomes <bf>3b</bf>-<bf>3e</bf> (and <bf>3f</bf>) when left or right
Ctrl is pressed already.
Second column of five:
<bf>e1 1d 45</bf> ((Break)/Clear/Pause/Test), and <bf>e0 46</bf>
with Ctrl, as expected for Pause/Break;
<bf>46</bf> (ScrLock), as expected for ScrLock;
<bf>e0 2a e0 37</bf> (PrtSc/SysRq), and <bf>e0 37</bf> with
left or right Ctrl or left or right Shift, and <bf>54</bf>
with left or right Alt, as expected for PrtSc;
<bf>1d 3f</bf> (ChgSc/WSCtrl), as expected for Ctrl F5;
<bf>38 e0 49</bf> (Jump), as expected for Alt PgUp.
<p>
On <htmlurl name="the right" url="nokia-right.jpg"> a cursor key
section and a number pad.
The cursor key section has the expected block of six:
<bf>e0 52</bf> (Dup/Insert/PA1);
<bf>e0 47</bf> (Field Mark/Home/PA2);
<bf>e0 49</bf> (PA3/PgUp);
<bf>e0 53</bf> (Delete/DelWd);
<bf>e0 4f</bf> (ErEOF/End/ErInp);
<bf>e0 51</bf> (PgDn).
Next four arrow keys:
<bf>e0 48</bf> (Up);
<bf>e0 4b</bf> (Left);
<bf>e0 4d</bf> (Right);
<bf>e0 50</bf> (Down).
And in the middle <bf>1d 40</bf> (Home), with code as expected for Ctrl F6.
<p>
Finally the numeric keypad, with the usual keys that generate the
usual codes, and a single additional key, a Tab, with <bf>0f</bf>
like the ordinary tab.
<p>
<figure><eps file="absent"><img src="nokia-s.jpg"></figure>

<sect1>Focus KeyPro FK-9000 keyboard
<label id="focus">
<p>
Raul D. Miller &lt;<tt/rockwell@nova.umd.edu/&gt;
and Timothy C. Hagman &lt;<tt/hagmanti@cps.msu.edu/&gt;
<!-- and William Setzer? -->
report:
<p>
<it>
The keyboard is a KeyPro FK-9000.  The FCC label says it's made in
Taiwan by Focus Electronic Co, Ltd.  It has a built-in calculator.
</it>
<p>
<it>
This keyboard has twelve additional keys, with scancodes
</it>
<bf>55</bf> (PF1),
<bf>6d</bf> (PF11),
<bf>6f</bf> (PF12),
<bf>73</bf> (PF2),
<bf>74</bf> (PF9),
<bf>77</bf> (PF3),
<bf>78</bf> (PF4),
<bf>79</bf> (PF5),
<bf>7a</bf>* (PF6),
<bf>7b</bf> (PF7),
<bf>7c</bf> (PF8),
<bf>7e</bf>* (PF10).
<p>
<it>
The break codes equal the make codes ORed with 0x80, as always,
but the Linux kernel eats <bf>fa</bf> and <bf>fe</bf> as
protocol bytes.
</it>
<p>
<it>
The behavior of these keys is different from that of normal keys--
they generate nothing when pressed; then generate the above scancodes
at the normal repeat time and rate, and then generate (except for the
starred ones) their scancode ORed with 0x80 when released...
</it>
<p>
<it>
These PF keys are reprogrammable -- and programming occurs as a sequence
of keyboard actions.  Therefore, the PF keys duplicate whatever
keyboard actions occurred during their programming.
You hit the "Prog" key, then the PF key you want to program; type the
string you want to store in the key (it's limited to 14 keypresses),
and then hit the PF key again. After that, when you hit the PF key,
it sends the string, and generates its own abnormal scancode upon
release. When the key is held down, it generates the scancode repeatedly,
but does not generate the string stored in it repeatedly.
</it>
<p>
<it>
When you go to program a key, the scancodes for "PF##-" are sent
to the computer, then the scancodes for each key you hit as you
hit it (the shift, etc. keys are an exception-- they send "s-"
and such :), and then, when you hit the PF## key again to end the
programming, it sends a sequence of (at least) 18 "0e 8e"s --
Backspaces...
</it>
<p>
<it>
The program key itself doesn't generate a scancode at any time.
The same applies to the CE and AC/ON keys (part of the calculator).
There is a switch to change between calculator and keyboard mode
which generates no scancodes.
</it>
<p>
<it>
When the keyboard is in calculator mode, the entire numeric
keypad (and everything else on the right side) generates no
scancodes.
</it>
<p>
<it>
When the keyboard is not in caluclator mode, the %, MC, MR, M-,
M+, and Square Root keys all generate 0xff when pressed,
0xff to repeat, and 0xff on release.
</it>
<p>
<it>
The little unlabeled key between the right Ctrl and right Alt
generates <bf>56</bf> when hit, repeats that, and then <bf>d6</bf>
when released, just like a normal key.
</it>
<p>

<sect1>BTC keyboard
<label id="BTC">
<p>
This keyboard has one additional key, with escaped scancode
<bf>e0</bf> <bf>6f</bf> (Macro). (Funny enough it does this
in all modes, each of the three scancode sets, translated or not.
In particular, this Macro key is the only key that generates
two bytes in scancode mode 3.)

<sect1>LK411 and LK450 keyboards<p>
These keyboards have seven additional keys, with escaped scancodes
<bf>e0</bf> <bf>0f</bf> (LeftCompose),
<bf>e0</bf> <bf>3d</bf> (F13),
<bf>e0</bf> <bf>3e</bf> (F14),
<bf>e0</bf> <bf>3f</bf> (Help),
<bf>e0</bf> <bf>40</bf> (Do),
<bf>e0</bf> <bf>41</bf> (F17),
<bf>e0</bf> <bf>4e</bf> (Keypad-minplus).
(LK411 has all seven. LK450 has the last six - the report did not
mention a Compose key.)
There are only two LEDs. The keycaps are unusual.

<sect1>OmniKey keyboard<p>
This keyboard has one additional key, with escaped scancode
<bf>e0</bf> <bf>4c</bf> (Omni).

<sect1>GRiD 2260 keyboard<p>
The GRiD 2260 notebook has a key producing the
<bf>6c</bf> scancode; I do not know the keycap.

<sect1>An old Olivetti keyboard<p>
Kasper Dupont &lt;kasperd@daimi.au.dk&gt; writes:
My 10 year old 102-key keyboard that came with an "Olivetti PCS 286"
actually has connectors for three additional keys just bellow Delete, End,
and PgDn. There is no keys on the connectors, I only found them because I
opened the keyboard for cleaning. The scancodes are from left to right
<bf>65</bf>, <bf>66</bf>, <bf>67</bf>.

<sect1>Cherry G81-3000
<label id="cherry81">
<p>
According to <htmlurl name="Delorie"
url="http://www.delorie.com/djgpp/doc/rbinter/it/06/0.html">
the "Cherry G81-3000 SAx/04" keyboard has four additional keys,
which can be made available by a user modification;
the three new keys located directly below the cursor pad's
Delete, End, and PgDn keys send make codes <bf>66</bf>-<bf>68</bf> (F19-F21);
the fourth new key, labeled (delta), sends make code <bf>73</bf>.

<sect1>Accord keyboard<p>
According to <htmlurl name="Delorie"
url="http://www.delorie.com/djgpp/doc/rbinter/it/06/0.html">
the "Accord" <htmlurl name="ergonomic keyboard"
url="http://www.ergonomics.co.uk/products/input/keyb7300.jpg">
with optional touchpad has an additional key above the Grey-Minus key
marked with a left-pointing triangle and labeled "Fn" in the owner's
booklet which sends make code <bf>e0 68</bf>.        

<sect1>Trust Ergonomic keyboard<p>
Frank v Waveren &lt;<tt/fvw@var.cx/&gt; reports:
The Trust Ergo Track keyboard has one additional key (`application key'), with
escaped scancode <bf>e0</bf> <bf>68</bf>. The keycap is a triangle pointing left.

<sect1>Brazilian keyboards<p>
ABNT (Associação Brasileira de Normas Tecnicas) and ABNT2
are Brazilian keyboard layout standards. The plain Brazilian
keyboard has 103 keys.
<p>
The Brazilian ABNT keyboard has two unusual keys,
with scancodes <bf>73</bf> (/?) and <bf>7e</bf> (Keypad-.).
The former is located to the left of the RShift (which
key therefore is less wide than usually), the latter below
the Keypad-Plus (reducing the Keypad-Plus to single height).
<p>
Under Linux, the corresponding key codes are 89 and 121, respectively.
These keys do not function with Windows NT 4.0.
<p>
Antonio Dias &lt;<tt/accdias@sst.com.br/&gt; provided the
<htmlurl url="abnt-keypad.html" name="keypad layout">
<!--
<p><table><tabular ca="ccccccccc">
NumLock  |  /     |     *    | - |  | 69 | 98 | 55 | 74 @
Home / 7 | Up / 8 | PgUp / 9 | + |  | 71 | 72 | 73 | 78 @
Left / 4 |  5     | Right / 6| . |  | 75 | 76 | 77 | 121 @
End / 1  |Down / 2| PgDn / 3 |Enter|| 79 | 80 | 81 | 96 @
Ins / 0  |Ins / 0 | Del / ,  |Enter|| 82 | 82 | 83 | 96 @
</tabular></table>
-->
and writes: <it>Brazilian ABNT2 keyboards come with two layouts.
In MSDOS they call them ID 274 and ID 275.</it>

<sect1>RC930 keyboard
<label id="RC930">
<p>
Torben Fjerdingstad &lt;<tt/tfj@olivia.ping.dk/&gt; reports:
<p>
<it>
It's an rc930 keyboard, from Regnecentralen/RC International, Now ICL.
This keyboard has four additional keys, with scancodes
</it>
<bf>59</bf> (A1),
<bf>5a</bf> (A2),
<bf>5b</bf> (A3),
<bf>5c</bf> (A4).
<p>
<it>
The rc930/rc931 keyboards are not made anymore, because they had a
problem with fast typists, writing over 400 chars/minute.
Writing 'af&lt;space&gt;', very, very fast, did a PgUp.
</it>

<sect1>Tandberg Data keyboard
<label id="prefix_80">
<p>
Kjetil Torgrim Homme &lt;<tt/kjetilho@ifi.uio.no/&gt; reports:
<p>
<it>
My Tandberg Data keyboard uses the prefix <bf>80</bf> for
its numerous (20) extra keys. The <bf>80</bf> scancodes are:
</it><p>
<bf>11</bf>, <bf>12</bf>, <bf>13</bf>, <bf>14</bf>, <bf>16</bf>,
<bf>17</bf>, <bf>18</bf>, <bf>19</bf>, <bf>1e</bf>, <bf>1f</bf>,
<bf>20</bf>, <bf>21</bf>, <bf>22</bf>, <bf>23</bf>, <bf>25</bf>,
<bf>26</bf>, <bf>2f</bf>, <bf>30</bf>, <bf>32</bf>, <bf>56</bf>.
<p><it>
For completeness, the <bf>e0</bf> scancodes:
</it><p>
<bf>1c</bf>, <bf>2a</bf>, <bf>35</bf>, <bf>37</bf>, <bf>47</bf>,
<bf>48</bf>, <bf>49</bf>, <bf>4b</bf>, <bf>4d</bf>, <bf>4f</bf>,
<bf>50</bf>, <bf>51</bf>, <bf>52</bf>, <bf>53</bf>.
<p><it>
The <bf>e1</bf> scancode: <bf>1d</bf>.
As you can see, there is no overlap on this keyboard.
</it>
<p>
Harald Arnesen &lt;<tt/gurre@start.no/&gt; gives the keycaps
for these for the Tandberg TDV5020 keyboard.
All use prefix <bf>80</bf> on both press and release.
<p>
Thirteen keys have (Norwegian) text:
<bf>11</bf> HJELP (help), <bf>14</bf> STRYK (cut),
<bf>16</bf> KOPI (copy), <bf>17</bf> FLYTT (move),
<bf>19</bf> JUST (justify), <bf>21</bf> MERK (mark),
<bf>22</bf> ANGRE (undo), <bf>23</bf> SKRIV (print),
<bf>25</bf> SLUTT (exit), <bf>26</bf> FELT (field),
<bf>2f</bf> AVSN (paragraph), <bf>30</bf> SETN (sentence),
and <bf>32</bf> ORD (word).
<p>
Seven keys have symbols: <bf>12</bf> /\/\/\ (insert soft hyphen),
<bf>13</bf> [Crossed down-arrow] (move down five lines),
<bf>18</bf> &gt;&gt; &lt;&lt; (justify left/right),
<bf>1e</bf> &lt;&gt; &gt;&lt; (justify full/center),
<bf>1f</bf> |&lt;- (backtab),
<bf>20</bf> -&gt;| (tab), and
<bf>56</bf> [Back/down arrow] (start new paragraph).
<p>
Other keycaps also occur. Those given above were meant
for use with the Notis WP word processor.

<sect1>Host Connected keyboard<p>
IBM makes the "Host Connected Keyboard" for PS/2 machines used as
3270 emulators.
<htmlurl name="Delorie"
url="http://www.delorie.com/djgpp/doc/rbinter/it/06/0.html">
reports on the 122-key "Host Connected" keyboard.
It may have <bf>5b</bf> (F13), <bf>5c</bf> (F14), <bf>5d</bf> (F15),
<bf>63</bf> (F16), <bf>64</bf> (F17), <bf>65</bf> (F18),
<bf>66</bf> (F19), <bf>67</bf> (F20), <bf>68</bf> (F21),
<bf>69</bf> (F22), <bf>6a</bf> (F23), <bf>6b</bf> (F24).

<sect1>A Chinese keyboard<p>
Bruno Haible &lt;<tt/haible@ilog.fr/&gt; reports:
The keyboard has three keys <bf>e0</bf> <bf>5e</bf> (Power),
<bf>e0</bf> <bf>5f</bf> (Sleep), <bf>e0</bf> <bf>63</bf> (WakeUp)
in the following positions:

<p><table><tabular ca="lllll">
  | F10 F11 F12 | Power  | Sleep  | WakeUp @@
..| Backspace   | PrtScr | ScrLck | Pause @
..| Return      | Ins    | Home   | PgUp @
..| Return      | Del    | End    | PgDn @
</tabular></table>

<sect1>A nameless USB keyboard<p>
This keyboard has four additional keys: Power (rose), Sleep (blue),
WakeUp (green) and FN (yellow).
In legacy mode these keys give the expected keycodes
(<bf>e0</bf> <bf>5e</bf>, <bf>e0</bf> <bf>5f</bf>, <bf>e0</bf> <bf>63</bf>,
and none, respectively), but the interaction is funny.
The four keys act as radiobuttons. Pressing one yields its key down code,
but releasing it does not produce any scancodes. Now pressing another
yields the down code for the other followed by the up code for the
previous one. The FN key follows this pattern, only its scancode sequence
is empty. Thus, pressing it causes the release code for a previous key
to be emitted. Pressing a key a second time gives no reaction: the radiobutton
was down already.

<sect1>Omnibook keyboard<p>
<label id="omnibookinit">
The HP Omnibook XE3 laptop has special multimedia keys (aka OneTouch buttons)
disabled by default. It is enabled by writing 0x59 to port 0x64
and then 0x90 to port 0x60 (as was found by Pavel Mihaylov).
Various kernel patches can be found on the net. See, for example,
<htmlurl name="this one"
url="http://zurich.ai.mit.edu/pipermail/omnibook/2002-April/001230.html">.

Keys (on a GF model):
<p>
<bf>e0</bf> <bf>32</bf> (WWW),
<bf>e0</bf> <bf>6c</bf> (Mail),
<bf>e0</bf> <bf>74</bf> (Demo),
<bf>e0</bf> <bf>73</bf> (Help),
<bf>e0</bf> <bf>10</bf> (Previous Track),
<bf>e0</bf> <bf>22</bf> (Play / Pause),
<bf>e0</bf> <bf>24</bf> (Stop / Eject),
<bf>e0</bf> <bf>19</bf> (Next Track),
<bf>e0</bf> <bf>2e</bf> (Volume Down),
<bf>e0</bf> <bf>30</bf> (Volume Up),
<bf>e0</bf> <bf>20</bf> (Mute / Unmute).
<p>

<!-- It seems press and release codes are the same.
Probably not. Only the kernel messages "unknown scancode"
are repeated, but there the top bit has been deleted already. -->

<sect1>EZ Button keyboard<p>
Eric Schott &lt;<tt/eric@morningjoy.com/&gt; writes:
<p>
I have an IBM EZ Button keyboard (US layout), which seems to
generate codes that are similar - but not identical - to the
Rapid Access keycodes listed above.
<p>
There are 14 additional keys:
<p>
<bf>e0</bf> <bf>25</bf> ("Power" moon - has an LED),
<bf>e0</bf> <bf>26</bf> ("Help"),
<bf>e0</bf> <bf>32</bf> ("Internet"),
<bf>e0</bf> <bf>17</bf> ("Lotus Word Pro"),
<bf>e0</bf> <bf>30</bf> ("Lotus Organizer"),
<bf>e0</bf> <bf>2e</bf> ("Aptiva Installer"),
<bf>e0</bf> <bf>19</bf> ("Delete Message"),
<bf>e0</bf> <bf>24</bf> (Stop),
<bf>e0</bf> <bf>22</bf> (Pause),
<bf>e0</bf> <bf>1e</bf> ("Msg" - has an LED),
<bf>e0</bf> <bf>20</bf> ("CD" - has an LED),
<bf>e0</bf> <bf>23</bf> (Rewind),
<bf>e0</bf> <bf>21</bf> (Fast Forward), and
<bf>e0</bf> <bf>12</bf> ("Talk" - has an LED).
<p>
<p>The LEDs in the buttons are controlled by the sequence <bf>eb</bf>
<bf>00</bf> <bf>xx</bf>
where the <bf>xx</bf> controls the LEDs. Bit 0 controls the "Msg" LED,
1 the CD LED, 2 the Power LED, 4 the Talk LED, and 5 the Message
waiting LED.
<p>

<sect1>Chicony KBP-8993 keyboard<p>
<label id="chicony">
Matthijs Melchior &lt;<tt/mmelchio@xs4all.nl/&gt; reports:
<p>
The Chicony KBP-8993 keyboard is similar. It has 14 additional
keys, enabled by sending <bf>ea</bf> <bf>71</bf> and disabled
by sending <bf>ea</bf> <bf>70</bf>.

These keys generate the following scan codes:
<p>
<bf>e0</bf> <bf>25</bf> (Moon),
<bf>e0</bf> <bf>32</bf> (WWW),
<bf>e0</bf> <bf>30</bf> (DOS),
<bf>e0</bf> <bf>17</bf> (MyDoc),
<bf>e0</bf> <bf>26</bf> (Menu),
<bf>e0</bf> <bf>1e</bf> (zzZ),
<bf>e0</bf> <bf>2e</bf> (Close),
<bf>e0</bf> <bf>24</bf> (Stop),
<bf>e0</bf> <bf>23</bf> (Back),
<bf>e0</bf> <bf>22</bf> (Play),
<bf>e0</bf> <bf>21</bf> (Forward),
<bf>e0</bf> <bf>20</bf> (Mute),
<bf>e0</bf> <bf>12</bf> (VolDown),
<bf>e0</bf> <bf>19</bf> (VolUp).

The two extra leds, above the Moon key, and next to the zzZ key
are manipulated by sending: <bf>eb</bf> <bf>00</bf> <bf>0x</bf>,
where bit 0 is the Moon led and bit 1 is the zzZ led.

<sect1>Keyboards for HP Kayak and Vectra<p>
Fons Rademakers &lt;<tt/Fons.Rademakers@cern.ch/&gt; writes:
<p>
<it>
The electronics for this keyboard was first developed by HP's
Home Products Division (HPD).
They now make improved versions, which I don't know much about.
We (HP Corporate PC Divisions, in Grenoble) reused the electronics,
and changed the serigraphy printed on the keys.
</it>
<p><table>
<tabular ca="cccccccccccccccccccc">
 |Msg|TTl|WWW| ? |Lck| |
 |Msg|Phn|WWW|xxx|Slp| |
 |133|134|135|136|137| @
 |Phn|S3 |S4 |S5 | i | |
 |&lt;&lt;|&gt;&verbar;&verbar;|&lsqb;&rsqb; |&gt;&gt; |HP | |
 |138|139|140|141|142| @
 |   |   |   |   |Mut| |
 |   |   |   |   |Mut| |
 |   |   |   |   |143| @
 |   |   |   |   |Vl+| |
 |   |   |   |   |Vl+| |
 |   |   |   |   |144| @
 |   |   |   |   |VL-| |
 |   |   |   |   |VL-| |
 |   |   |   |   |145| @
</tabular>
<caption>
Grenoble keyboard ------- Old HPD keyboard -------- key numbers
</caption>
</table>

<p><table><tabular ca="ccccc">
 | Key# | Scancode | Gren. Name | HPD name | ASCII @@
 | 133 | <bf>e0 1e</bf> | Message/SC1 | Message | a @
 | 134 | <bf>e0 12</bf> | Top Tools | Phone | e @
 | 135 | <bf>e0 32</bf> | Web Browser | Internet | m @
 | 136 | <bf>e0 17</bf> | Reminder | Shortcut | i @
 | 137 | <bf>e0 25</bf> | Lock | Suspend | k @
 | 138 | <bf>e0 23</bf> | Phone/SC2 | &lt;&lt; | h @
 | 139 | <bf>e0 22</bf> | ShortCut 3 | &gt;&verbar;&verbar; | g @
 | 140 | <bf>e0 24</bf> | ShortCut 4 | &lsqb;&rsqb; | j @
 | 141 | <bf>e0 21</bf> | ShortCut 5 | &gt;&gt; | f @
 | 142 | <bf>e0 26</bf> | Information | Information | l @
 | 143 | <bf>e0 20</bf> | Mute | Mute | d @
 | 144 | <bf>e0 30</bf> | Volume + | Volume + | b @
 | 145 | <bf>e0 2e</bf> | Volume - | Volume - | c @
</tabular></table>

<it>
Note the scancodes above are those read by x86 software in port 0x60.
This is also called Scancode Set 1.
Break codes are the same, with bit 7 of the second scancode set.
Example:</it> <bf>e0 9e</bf> <it>for the Message key.
</it>

<p>
&lt;<tt/spikboll@gmx.net/&gt; adds:
<it>These keyboards have a "mail LED" (it's positioned above the Message
button) that kan be controlled by the Rapid Access hack:</it>
'send_to_keyboard <bf>eb</bf>' <it>makes the led blink and</it>
'send_to_keyboard <bf>ec</bf>' <it>turns the led off.</it>
'send_to_keyboard <bf>ed</bf>' <it>makes the led light steadily
and locks up the keys.</it>

<sect1>A keyboard<p>
Jon Masters &lt;<tt/jonathan@easypenguin.co.uk/&gt; writes:
<p><it>
My new 121 key keyboard has 105 keys + 16 multimedia keys
(including cool stuff like a volume jog dial that sends one scancode
when turned one way and anther when turned the opposite way).
</it>
<p>
<bf>e0</bf> <bf>5e</bf> (Power Off),
<bf>e0</bf> <bf>5f</bf> (Sleep),
<bf>e0</bf> <bf>63</bf> (Resume),
<bf>e0</bf> <bf>2e</bf> (Help),
<bf>e0</bf> <bf>20</bf> (My Favourite),
<bf>e0</bf> <bf>30</bf> (Browser),
<bf>e0</bf> <bf>32</bf> (WWW Search),
<bf>e0</bf> <bf>26</bf> (Shortcut),
<bf>e0</bf> <bf>25</bf> (Volume Down),
<bf>e0</bf> <bf>1e</bf> (Volume Up),
<bf>e0</bf> <bf>12</bf> (Mute),
<bf>e0</bf> <bf>22</bf> (Previous),
<bf>e0</bf> <bf>10</bf> (Stop),
<bf>e0</bf> <bf>24</bf> (Next),
<bf>e0</bf> <bf>21</bf> (Eject),
<bf>e0</bf> <bf>19</bf> (Play).

<sect1>Yahoo! keyboard<p>
Bernhard Polzin &lt;<tt/B.Polzin@web.de/&gt; writes:
<p><it>
I have a transparent violet colored "Yahoo!" Keyboard with extra keys
for Internet and Audio. Unusual scancodes (untranslated/translated):
</it>
<p>
<bf>e0</bf> <bf>37</bf> / <bf>e0</bf> <bf>5e</bf> (Power),
<bf>e0</bf> <bf>3f</bf> / <bf>e0</bf> <bf>5f</bf> (Sleep),
<bf>e0</bf> <bf>5e</bf> / <bf>e0</bf> <bf>63</bf> (Wake),
<bf>e0</bf> <bf>21</bf> / <bf>e0</bf> <bf>2e</bf> (Y!),
<bf>e0</bf> <bf>4b</bf> / <bf>e0</bf> <bf>26</bf> (Short Cut),
<bf>e0</bf> <bf>3a</bf> / <bf>e0</bf> <bf>32</bf> (E-Mail),
<bf>e0</bf> <bf>23</bf> / <bf>e0</bf> <bf>20</bf> (My Doc),
<bf>e0</bf> <bf>32</bf> / <bf>e0</bf> <bf>30</bf> (WWW),
<bf>e0</bf> <bf>1c</bf> / <bf>e0</bf> <bf>1e</bf> (Volume +),
<bf>e0</bf> <bf>42</bf> / <bf>e0</bf> <bf>25</bf> (Volume -),
<bf>e0</bf> <bf>24</bf> / <bf>e0</bf> <bf>12</bf> (Mute),
<bf>e0</bf> <bf>15</bf> / <bf>e0</bf> <bf>10</bf> (Stop),
<bf>e0</bf> <bf>4e</bf> / <bf>e0</bf> <bf>0c</bf> (Play/Pause), 
<bf>e0</bf> <bf>34</bf> / <bf>e0</bf> <bf>22</bf> (Prev Track),
<bf>e0</bf> <bf>3d</bf> / <bf>e0</bf> <bf>08</bf> (Next Track),
<bf>e0</bf> <bf>4d</bf> / <bf>e0</bf> <bf>19</bf> (Eject).
<it>(Volume +), (Volume -), (Prev Track) and (Next Track) are typematic.</it>
<p>
Note that this is very similar to the previous one.
<p>
<figure><eps file="absent"><img src="yahoo912.jpg"></figure>
<!-- photograph from
http://shop.store.yahoo.com/ygear/yah912.html
-->

<sect1>Honeywell Multimedia Keyboard
<label id="honeywell">
<p>
Eric Yeo reports that his Honeywell Multimedia Keyboard has the following
additional keys:
<bf>e0</bf> <bf>25</bf> (Screen saver),
<bf>e0</bf> <bf>24</bf> (Mail),
<bf>e0</bf> <bf>32</bf> (WWW),
<bf>e0</bf> <bf>10</bf> (Game),
<bf>e0</bf> <bf>26</bf> (Calc),
<bf>e0</bf> <bf>1e</bf> (Shortcut 1),
<bf>e0</bf> <bf>18</bf> (Shortcut 2),
<bf>e0</bf> <bf>12</bf> (Prev),
<bf>e0</bf> <bf>22</bf> (Next),
<bf>e0</bf> <bf>19</bf> (Play),
<bf>e0</bf> <bf>23</bf> (Stop),
<bf>e0</bf> <bf>30</bf> (Vol up),
<bf>e0</bf> <bf>2e</bf> (Vol down),
<bf>e0</bf> <bf>17</bf> (Eject),
<bf>e0</bf> <bf>20</bf> (Mute).

<sect1>Samsung Ergonomics Keyboard
<p>
Miguel Costa reports that his <htmlurl name="Samsung Ergonomics Keyboard"
url="samsung.jpg"> has the following additional keys:
<bf>e0</bf> <bf>2e</bf> (Vol down),
<bf>e0</bf> <bf>30</bf> (Vol up),
<bf>e0</bf> <bf>20</bf> (Mute),
<bf>e0</bf> <bf>18</bf> (Eject),
<bf>e0</bf> <bf>22</bf> (PlayPause),
<bf>e0</bf> <bf>24</bf> (Stop),
<bf>e0</bf> <bf>10</bf> (Rewind),
<bf>e0</bf> <bf>19</bf> (Forward),
<bf>e0</bf> <bf>26</bf> (Help),
<bf>e0</bf> <bf>59</bf> (Favorites),
<bf>e0</bf> <bf>09</bf> (Exit),
<bf>e0</bf> <bf>0a</bf> (Address book),
<bf>e0</bf> <bf>02</bf> (Action 1),
<bf>e0</bf> <bf>03</bf> (Action 2),
<bf>e0</bf> <bf>04</bf> (Action 3),
<bf>e0</bf> <bf>05</bf> (Action 4),
<bf>e0</bf> <bf>06</bf> (Action 5),
<bf>e0</bf> <bf>32</bf> (Internet),
<bf>e0</bf> <bf>6c</bf> (Email),
<bf>e0</bf> <bf>5f</bf> (Standby),
<bf>e0</bf> <bf>5b</bf> (Windows left),
<bf>e0</bf> <bf>5c</bf> (Windows right),
<bf>e0</bf> <bf>5d</bf> (Windows task).
<p>
<figure><eps file="absent"><img src="samsung-s.jpg"></figure>

<sect1>The "LiteOn MediaTouch Keyboard" type SK-2500<p>
Serge van den Boom reports that his LiteOn MediaTouch Keyboard
(a Trust "Direct Access Keyboard"), has 18 additional keys:
<bf>e0</bf> <bf>25</bf> (Suspend),
<bf>e0</bf> <bf>7a</bf> (Coffee),
<bf>e0</bf> <bf>32</bf> (WWW),
<bf>e0</bf> <bf>21</bf> (Calculator),
<bf>e0</bf> <bf>23</bf> (Xfer),
<bf>38</bf> <bf>2a</bf> <bf>0f</bf> <bf>8f</bf> / <bf>8f</bf> <bf>b8</bf>
<bf>aa</bf> (Switch window),
<bf>e0</bf> <bf>17</bf> (Close),
<bf>e0</bf> <bf>10</bf> (|<<),
<bf>e0</bf> <bf>22</bf> (>| / []),
<bf>e0</bf> <bf>24</bf> ([]),
<bf>e0</bf> <bf>19</bf> (>>|),
<bf>e0</bf> <bf>1e</bf> (Record),
<bf>e0</bf> <bf>12</bf> (Rewind),
<bf>e0</bf> <bf>26</bf> (Menu/?),
<bf>e0</bf> <bf>18</bf> (Eject),
<bf>e0</bf> <bf>20</bf> (Mute),
<bf>e0</bf> <bf>30</bf> (Volume +),
<bf>e0</bf> <bf>2e</bf> (Volume -).
Of these, the keys (|<<), (>>|), (Volume +), (Volume -) repeat.
The others do not, except for the rather special (Switch window)
key. Upon press it produces the LAlt-down, LShift-down, Tab-down,
Tab-up sequence; it repeats <bf>0f</bf>, that is, Tab-down;
and upon release it produces the Tab-up, LAlt-up, LShift-up sequence.
<p>
<figure><eps file="absent"><img src="sk2500.jpg"></figure>
<p>

<sect1>Keyboards with many keys<p>
The current mechanism is unable to handle keyboards with more than
127 keys. But such keyboards seem to exist. Indeed, I now have a
<ref id="safeway23" name="Safeway SW23"> that has 132 keys.

Mark Hatle &lt;<tt/fray@kernel.crashing.org/&gt; wrote:
<p>
<it>
On some ADB keyboards there are actually 128 distinct keys.
They use scancodes 0-127.
</it><p><it>
ADB is Apple Desktop Bus.  The way that ADB works is similar to SCSI but
on a much slower level.  Specifically there is a communications chip in
the computer, ADB controller, and the same chip in the keyboard.  The
keyboard sends the scancode to its internal ADB controller, the internal
ADB controller then does any key mapping needed (not used under linux
from my understanding) and passes the data to the computer.
</it><p><it>
The ADB controller is capable of sending 256 distinct keys, but to my
knowledge only 128 are sent.  The key 0 is the 'a' and key 127 is the
"power button".
</it><p><it>
Also some of the Apple ADB keyboards have special "sound" and "function"
keys.  These keys (used in MacOS for volume up and down, screen contrast
changing, etc) also show up on the ADB scancodes.
</it><p><it>
ADB is used for both m68k and PPC Linux.  The m68k Macintosh port, and
the PPC - Power Macintosh and CHRP ports.
</it><p>
and later:
<p><it>
Basically the scancode sequences for ADB are 16 bit. so there can actually
be 65536 scancodes, currently though only 128 are defined.
</it>

<sect1>A keyboard treating PrtSc/SysRq like Pause/Break<p>
<label id="mtek">
Mike A. Harris &lt;<tt/mharris@meteng.on.ca/&gt;
reports a keyboard (an "Mtek" keyboard, model "K208")
where PrtSc/SysRq behaves like Pause/Break and also sends both make
and break sequences when pressed and nothing when released.
It does not repeat.
(Thus, he gets <bf>e0</bf> <bf>2a</bf> <bf>e0</bf> <bf>37</bf>
<bf>e0</bf> <bf>b7</bf> <bf>e0</bf> <bf>aa</bf> for PrtSc press,
and <bf>54</bf> <bf>d4</bf> for SysRq (i.e., Alt+PrtSc).)
Others have reported the same (for an unspecified type of keyboard).

<sect>Japanese keyboards
<label id="japanese">
<p>

<!-- <META http-equiv=Content-Type content="text/html; charset=shift_jis"> -->

<figure><eps file="absent"><img src="jp106.jpg"></figure>
<figure><eps file="absent"><img src="jp106-with-scancodes.jpg"></figure>

<sect1>Japanese 86/106 keyboards<p>
(Information from Barry Yip &lt;<tt/g609296@cc.win.or.jp/&gt;,
Norman Diamond, NIIBE Yutaka and H. Peter Anvin, who
contributed the photographs of his
JP106 keyboard above and of his
<htmlurl url="jplaptop.jpg" name="Japanese laptop">.)
<p>
Common Japanese keyboards have five additional keys
(106-key, or 86-key for a notebook; these days there may also
be 3 extra Windows keys). These keys have scancodes
<bf>70</bf> (hiragana/katakana),
<bf>73</bf> (backslash/underscore),
<bf>79</bf> (henkan/zenkouho),
<bf>7b</bf> (muhenkan),
<bf>7d</bf> (yen/vertical bar).
<p>
Scancode <bf>0b</bf> is zero/tilde. (Some keyboards
have the tilde printed on the keycap, and some don't.)
Scancode <bf>0d</bf> is circumflex/overbar.
Scancode <bf>29</bf> is hankaku/zenkaku.
<p>
(ASCII and JIS-Roman differ in two or three points: the code positions
where ASCII has backslash, tilde, broken bar,
JIS-Roman uses yen, overbar and vertical bar, respectively.)
<p>
<sect1>Description of the all-Japanese keys<p>
Norman Diamond adds to the previous section:

<it>To the left of the spacebar,</it>
<!-- (iso-2022-jp) &#27;$BL5JQ49&#27;(B -->
(Shift-JIS) &#150;³&#149;Ï&#138;·
<it>(muhenkan) means no conversion
from kana to kanji.  To the right of the spacebar,
<!-- (iso-2022-jp) &#27;$BJQ49&#27;(B -->
&#149;Ï&#138;·
(henkan) means conversion from kana to kanji. In Microsoft systems
it converts the most recently input sequence of kana to the system's
first guess at a string of kanji/kana/etc. with the correct pronunciation
and a guess at the meaning. Repeated keypresses change it to other
possible guesses which are either less common or less recently used,
depending on the situation. The shifted version of this key is
<!-- (iso-2022-jp) &#27;$BA08tJd&#27;(B -->
&#145;O&#140;ò&#149;â
(zenkouho) which means "previous candidate" -- "zen" means "previous",
while "kouho" means "candidate"</it> (explanation courtesy of NIIBE Yutaka)
<it>-- it rotates back to earlier guesses for kanji conversion.
The alt version of this key is
<!-- (iso-2022-jp) &#27;$BA48tJd&#27;(B -->
&#145;S&#140;ò&#149;â
also pronounced (zenkouho), which means "all candidates" -- here,
"zen" means "all" -- it displays a menu of all known guesses.
I never use the latter two functions of the key, because after
pushing the henkan key about three times and not getting the desired guess,
it displays a menu of all known guesses anyway.</it>

<it>Next on the right,
<!-- (iso-2022-jp) &#27;$B$R$i$,$J&#27;(B -->
&#130;Ð&#130;ç&#130;ª&#130;È
(hiragana) means that
phonetic input uses one conventional Japanese phonetic alphabet,
which of course can be converted to kanji by pressing the henkan key later.
The shifted version is
<!-- (iso-2022-jp) &#27;$B%+%?%+%J&#27;(B -->
&#131;J&#131;^&#131;J&#131;i
(katakana) which means the other Japanese phonetic alphabet,
and the alt version is
<!-- (iso-2022-jp) &#27;$B%m!<%^;z&#27;(B -->
&#131;&#141;&#129;[&#131;}&#142;&#154;
(ro-maji) which means the Roman alphabet.</it>

<it>Near the upper left,
<!-- (iso-2022-jp) &#27;$BH>&#27;(B/&#27;$BA4&#27;(B -->
&#148;¼/&#145;S
(han/zen) means switch between hankaku
(half-size, the same size as an ASCII character) and zenkaku
(full-size, since the amount of space occupied by a kanji
is approximately a square, twice as fat as an ASCII character).
It only affects katakana and a few other characters
(for example there's a full-width copy of each ASCII character
in addition to the single-byte half-width encodings).
The alt version of this is
<!-- (iso-2022-jp) &#27;$B4A;z&#27;(B -->
&#138;¿&#142;&#154;
(kanji) which
actually causes typed Roman phonetic keys to be displayed as Japanese
phonetic kana (either hiragana or katakana depending on one of the other
keys described above) and doesn't cause conversion to kanji.
</it>

<sect1>A keyboard using e0 as ordinary scancode
<label id="e0_as_key">
<p>
Benjamin Carter &lt;<tt/bcarter@ultra5.cs.umr.edu/&gt; reports:
<p>
<it>
I recently came into possession of a 97-key keyboard with Japanese
markings on the keys.  (The keys also have the standard
qwerty-characters on them, with the exception of some of the meta-keys
(there are 3 keys near the Alt keys on either side of the spacebar with
only Japanese characters on them so I don't know what they are).
In any case, the keyboard sends out scancodes that work for all the main
keys (backspace, letters and numbers, enter, shift), but the numeric
keypad, Alt keys, and function keys don't work.
I have run the board through <tt>showkey -s</tt>, so I know what
scancodes this keyboard sends out.
However, the F9 and F10 keys send out <bf>60</bf> and <bf>61</bf>,
respectively, so their key release events send out <bf>e0</bf>
and <bf>e1</bf>, confusing the keyboard driver.
</it>
<p>
# These are across the top of the keyboard.
<p>
<bf>58</bf> (F1), <bf>59</bf> (F2), <bf>5a</bf> (F3),
<bf>5b</bf> (F4), <bf>5c</bf> (F5), <bf>5d</bf> (F6),
<bf>5e</bf> (F7), <bf>5f</bf> (F8), <bf>60</bf> (F9),
<bf>61</bf> (F10), <bf>62</bf> (F11), <bf>63</bf> (F12)
<p> 
<bf>76</bf> (Break), <bf>77</bf> (Setup).
<p> 
# top row
<p>
<bf>64</bf> (Esc),
<bf>02</bf> (1), <bf>03</bf> (2), <bf>04</bf> (3),
<bf>05</bf> (4), <bf>06</bf> (5), <bf>07</bf> (6),
<bf>08</bf> (7), <bf>09</bf> (8), <bf>0a</bf> (9),
<bf>0b</bf> (0), <bf>0c</bf> (-), <bf>0d</bf> (=),
<bf>29</bf> (`), <bf>0e</bf> (Backspace)

<p>
# 2nd row
<p>
<bf>0f</bf> (Tab),
<bf>10</bf> (Q), <bf>11</bf> (W), <bf>12</bf> (E),
<bf>13</bf> (R), <bf>14</bf> (T), <bf>15</bf> (Y),
<bf>16</bf> (U), <bf>17</bf> (I), <bf>18</bf> (O),
<bf>19</bf> (P), <bf>1a</bf> ([), <bf>1b</bf> (]),
<bf>79</bf> (Del), <bf>6e</bf> (Line Feed)

<p>
# 3rd row
<p>
<bf>38</bf> (Ctrl),
<bf>1e</bf> (A), <bf>1f</bf> (S), <bf>20</bf> (D),
<bf>21</bf> (F), <bf>22</bf> (G), <bf>23</bf> (H),
<bf>24</bf> (J), <bf>25</bf> (K), <bf>26</bf> (L),
<bf>27</bf> (;), <bf>28</bf> ('), <bf>75</bf> (\),
<bf>1c</bf> (Return)

<p>
# 4th row
<p>
<bf>2a</bf> (Shift_L),
<bf>2c</bf> (Z), <bf>2d</bf> (X), <bf>2e</bf> (C),
<bf>2f</bf> (V), <bf>30</bf> (B), <bf>31</bf> (N),
<bf>32</bf> (M), <bf>33</bf> (,), <bf>34</bf> (.),
<bf>35</bf> (/),
<bf>3a</bf> ((unknown)),
<bf>36</bf> (Shift_R)

<p>
# bottom row
<p>
<bf>1d</bf> (Caps Lock), <bf>71</bf> (Alt_L),
<bf>01</bf> ((unknown)),
<bf>39</bf> (Space),
<bf>45</bf> ((unknown)),
<bf>72</bf> (Alt_R),
<bf>46</bf> ((unknown))

<p>
# numeric keypad.  No "grey" section on the keyboard.
<p>
<bf>47</bf> (7), <bf>48</bf> (8), <bf>49</bf> (9),
<bf>54</bf> (Keypad -),
<bf>4b</bf> (4), <bf>4c</bf> (5), <bf>4d</bf> (6),
<bf>37</bf> (Keypad +),
<bf>4f</bf> (1), <bf>50</bf> (2), <bf>51</bf> (3),
<bf>4e</bf> (Keypad Enter),
<bf>52</bf> (0),
<bf>78</bf> (Up),
<bf>53</bf> (Keypad .),
<bf>56</bf> (Left),
<bf>55</bf> (Down),
<bf>7d</bf> (Right),
<bf>7e</bf> (Keypad ,).
<p>

There are more keyboards that do not use <bf>e0</bf> as escape code.
For example, Paul Schulz &lt;<tt/pauls@caemrad.com.au/&gt;
reports the same for Sun Type 5 Keyboard with PS/2 connector,
NCD model N-123NA. A kernel patch is required for such keyboards.



<sect>Keyboard-internal scancodes
<label id="kscancodes">
<p>
<sect1>Three scancode sets<p>
The usual PC keyboards are capable of producing three sets of scancodes.
Writing 0xf0 followed by 1, 2 or 3 to port 0x60 will put the keyboard
in scancode mode 1, 2 or 3. Writing 0xf0 followed by 0 queries the mode,
resulting in a scancode byte 0x43, 0x41 or 0x3f from the keyboard.
<p>
Set 1 contains the values that the XT keyboard (with only one set
of scancodes) produced, with extensions for new keys. Someone
decided that another numbering was more logical and invented
scancode Set 2. However, it was realized that new scancodes
would break old programs, so the keyboard output was fed to a
8042 microprocessor on the motherboard that could translate Set 2
back into Set 1. Indeed a smart construction. This is the default today.
Finally there is the PS/2 version, Set 3, more regular, but used by
almost nobody.
<p>
(I wrote this long ago. Nowadays Linux 2.5 tries to use Set 3.
Also certain HP machines, like the PS/2 version of the HP9000
workstation, have used Set 3.)
<p>
Sets 2 and 3 are designed to be translated by the 8042.
Set 1 should not be translated.
<p>
Not all keyboards support all scancode sets. For example, my MyCom
laptop only supports scancode Set 2, and its keyboard does not react
at all when in mode 1 or 3.
<p>
<sect1>Make and Break codes<p>
The key press / key release is coded as follows:
For Set 1, if the make code of a key is <it>c</it>, the break code
will be <it>c</it>+0x80. If the make code is <bf>e0</bf> <it>c</it>,
the break code will be <bf>e0</bf> <it>c</it>+0x80.
The Pause key has make code <bf>e1</bf> <bf>1d</bf> <bf>45</bf>
<bf>e1</bf> <bf>9d</bf> <bf>c5</bf> and does not generate a break code.
For Set 2, if the make code of a key is <it>c</it>, the break code
will be <bf>f0</bf> <it>c</it>. If the make code is <bf>e0</bf> <it>c</it>,
the break code will be <bf>e0</bf> <bf>f0</bf> <it>c</it>.
The Pause key has make code <bf>e1</bf> <bf>14</bf> <bf>77</bf>
<bf>e1</bf> <bf>f0</bf> <bf>14</bf> <bf>f0</bf> <bf>77</bf>.
For Set 3, by default most keys do not generate a break code - only CapsLock,
LShift, RShift, LCtrl and LAlt do.
(On Microsoft keyboards, also LWin, RWin, Menu, Back, Forward, Stop,
Mail, Search, Favorites, Web/Home, MyComputer, Calculator, Sleep do.
On a BTC keyboard, also the Macro key does.)
However, in Scancode Mode 3 it is possible to enable or disable key repeat
and the production of break codes either on a key-by-key basis
or for all keys at once.
And just like for Set 2, key release is indicated by a <bf>f0</bf> prefix
in those cases where it is indicated.
There is nothing special with the Pause key in scancode mode 3.
<p>
<sect1>Translation<p>
The 8042 microprocessor translates the incoming byte stream produced
by the keyboard, and turns an <bf>f0</bf> prefix into an OR with
<bf>80</bf> for the next byte.
<label id="contagious">
(Some implementations do this for the next byte that does not have
this bit set already. A consequence is that in Set 3 the keys with Set-3
value 0x80 or more are broken in a peculiar way: hitting such a key and
then some other key turns the make code for this last key into a break code.
For example the Sleep key on a Microsoft Internet keyboard generates
<bf>54</bf> / <bf>d4</bf> for press/release. But pressing and
releasing first Menu and then Sleep produces
<bf>8d</bf> <bf>8d</bf> <bf>d4</bf> <bf>d4</bf> as translation of
<bf>8d</bf> <bf>f0</bf> <bf>8d</bf> <bf>54</bf> <bf>f0</bf> <bf>54</bf>.
Other implementations are OK.)
<p>
<label id="translationtable">
Unless told not to translate, the keyboard controller translates
kscancodes into scancodes using the following table (in hex):

<p><table><tabular ca="c|cccccccccccccccc">
   | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 0a | 0b | 0c | 0d | 0e | 0f @@
00 | ff | 43 | 41 | 3f | 3d | 3b | 3c | 58 | 64 | 44 | 42 | 40 | 3e | 0f | 29 | 59 @
10 | 65 | 38 | 2a | 70 | 1d | 10 | 02 | 5a | 66 | 71 | 2c | 1f | 1e | 11 | 03 | 5b @
20 | 67 | 2e | 2d | 20 | 12 | 05 | 04 | 5c | 68 | 39 | 2f | 21 | 14 | 13 | 06 | 5d @
30 | 69 | 31 | 30 | 23 | 22 | 15 | 07 | 5e | 6a | 72 | 32 | 24 | 16 | 08 | 09 | 5f @
40 | 6b | 33 | 25 | 17 | 18 | 0b | 0a | 60 | 6c | 34 | 35 | 26 | 27 | 19 | 0c | 61 @
50 | 6d | 73 | 28 | 74 | 1a | 0d | 62 | 6e | 3a | 36 | 1c | 1b | 75 | 2b | 63 | 76 @
60 | 55 | 56 | 77 | 78 | 79 | 7a | 0e | 7b | 7c | 4f | 7d | 4b | 47 | 7e | 7f | 6f @
70 | 52 | 53 | 50 | 4c | 4d | 48 | 01 | 45 | 57 | 4e | 51 | 4a | 37 | 49 | 46 | 54 @
80 | 80?| 81 | 82 | 41 | 54 | 85 | 86 | 87 | 88 | 89 | 8a | 8b | 8c | 8d | 8e | 8f @
90 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 9a | 9b | 9c | 9d | 9e | 9f @
a0 | a0 | a1 | a2 | a3 | a4 | a5 | a6 | a7 | a8 | a9 | aa | ab | ac | ad | ae | af @
b0 | b0 | b1 | b2 | b3 | b4 | b5 | b6 | b7 | b8 | b9 | ba | bb | bc | bd | be | bf @
c0 | c0 | c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 | c9 | ca | cb | cc | cd | ce | cf @
d0 | d0 | d1 | d2 | d3 | d4 | d5?| d6 | d7 | d8 | d9?| da?| db | dc | dd | de | df @
e0 | e0 | e1 | e2 | e3 | e4 | e5 | e6 | e7 | e8 | e9 | ea | eb | ec | ed | ee | ef?@
f0 |  - | f1?| f2?| f3?| f4?| f5?| f6?| f7?| f8?| f9?| fa?| fb?| fc?| fd?| fe?| ff @
</tabular></table>

A reference for the first half of this table is the book by Gary J Konzak
<it>PC 8042 Controller</it>, ISBN 0-929392-21-3.
(Report by <tt/vojtech@suse.cz/.)

A way to check this table is: (i) put the keyboard in untranslated modes
1, 2, 3 and look at the <htmlurl name="resulting values" url="table.h">,
and (ii) put the keyboard in translated scancode modes 1, 2, 3. Now compare
the values. The entries with question marks were not checked in this way.

Note that the range <bf>01</bf>-<bf>7f</bf> of this table is 1-1.
In the second half of the table, translated and untranslated values
are equal in all known cases, with the two exceptions <bf>83</bf> and <bf>84</bf>.

One asks the controller to transmit untranslated scancodes by writing
a keyboard controller command with bit 5 set and bit 6 cleared.
E.g., use the command byte <bf>45</bf> to get translated codes,
and <bf>24</bf> to get untranslated codes that do not cause interrupts.

<sect2>Effects of translation<p>
<sect3>Origin of strange scan code set values<p>
The keyboard command <bf>f0</bf> with argument 1, 2 or 3
sets the current scancode set, and this same command
with argument 0 asks for the current scancode set.
The reply is <bf>43</bf>, <bf>41</bf> or <bf>3f</bf>
for sets 1, 2, 3. Why? Because in reality the reply is 1, 2 or 3,
and that is what one sees when translation is off. But translation
turns these into <bf>43</bf>, <bf>41</bf>, <bf>3f</bf>.
<p>
<sect3>Keyboard IDs<p>
Keyboards do report an ID as a reply to the command <bf>f2</bf>.
(An XT keyboard does not reply, an AT keyboard only replies with an ACK.)
An MF2 AT keyboard reports ID <bf>ab</bf> <bf>83</bf>.
Translation turns this into <bf>ab</bf> <bf>41</bf>.
<p>
Many short keyboards, like IBM ThinkPads, and Spacesaver keyboards,
send <bf>ab</bf> <bf>84</bf> untranslated,
which becomes <bf>ab</bf> <bf>54</bf> translated.
(The netbsd source has a misunderstanding here, and seems to associate
the <bf>54</bf> and <bf>84</bf> to the ThinkPad model - cf. the defines
KEYB_R_MF2ID2TP75X, KEYB_R_MF2ID2TP76X.)
<p>
Several 122-key keyboards are reported to send <bf>ab</bf> <bf>86</bf>.
Here translated and untranslated values coincide.
(Reports mention "122-Key Enhanced Keyboard", "standard 122-key keyboard",
"122 Key Mainframe Interactive (MFI) Keyboard".)
<p>
Tim Clarke reports <bf>ab</bf> <bf>85</bf> for the
"122-Key Host Connect(ed) Keyboard".
<!-- in comp.sys.ibm.ps2.hardware, 2002-05-23 -->
<p>
He also reports
<it>Also, when playing with my KVM problems Belkin gave me a
105-key Windows keyboard which Id.s itself as 18ABh</it>.
<!-- in comp.sys.ibm.ps2.hardware, 2002-05-21 -->
<p>
Linux 2.5.25 kernel source has 0xaca1 for a
"NCD Sun layout keyboard". It also mentions 0xab02 and 0xab7f,
but these arise as (mistaken) back translations from
<bf>ab</bf> <bf>41</bf> and <bf>ab</bf> <bf>54</bf>.
<!-- Also 0xab03 on unxlated ThinkPad was mentioned,
probably a mistake. -->
<p>
Ralph Brown's Interrupt list mentions "old Japanese 'G', 'P', 'A' keyboards",
with keyboard IDs <bf>ab</bf> <bf>90</bf>, <bf>ab</bf> <bf>91</bf>,
<bf>ab</bf> <bf>92</bf>. Here translated and untranslated versions
coincide.
<p>

<sect1>Use<p>
Can these other scancode sets be used? Probably not.

() Translated scancode Set 1 has weird codes that nobody wants to use.

(i) My MyCom laptop does not support scancode sets 1 and 3 at all.

(ii) Some laptops have special key combinations that bring one
into a setup or configuration utility. It is impossible to do
anything useful, or to get out of it again, when the scancode mode
is not translated Set 2.

(iii) Many keyboards have bugs in scancode sets 1 and/or 3 but
are fine in scancode Set 2.
Vojtech Pavlik reports that his BTC keyboard has the same codes
for the '1' and '2' keys in Set3, both having the code for '1').
On my BTC keyboard the key up value for Esc and 1 are both <bf>ff</bf>
in scancode Set 1. My Safeway keyboard has untranslated Set 1 equal
to translated Set 2, except for the multimedia keys, where
untranslated Set 1 equals untranslated Set 2.

(iv) A big advantage of Set 3 is that each key generates a unique code
so that one does not need to parse sequences. However, the BTC keyboard
mentioned <ref id="BTC" name="above"> generates <bf>e0</bf> <bf>6f</bf>
for its Macro key also in scancode mode 3. The Safeway keyboard mentioned
<ref id="safeway23" name="above"> does not generate any codes
for its multimedia keys in scancode mode 3.

(v) Some keyboard controllers cannot handle Set 3 values that are
larger than 0x7f, and give <ref id="contagious" name="peculiar results">
for some keys on the Microsoft Internet keyboard in translated
scancode mode 3.

(vi) The USB legacy support only supports translated Set 2.

(vii) The <htmlurl name="Microsoft Keyboard Scan Code Specification"
url="http://www.microsoft.com/hwdev/download/desinit/scancode.zip"> writes:
<it>In the very early days of Windows NT, an attempt was made
to use the much more orthogonal Scan Code Set 3, but due to bugs
in the implementation of this Scan Code Set on numerous OEM
keyboards, the idea was abandoned.</it>
And also: <it>Scan Code Set 3 is not used or required for operation
of Microsoft operating systems.</it>

(viii) Others also tried Set 3. The PS/2 version of the HP9000
workstation uses it. This is fine with HP's keyboards but causes
some problems with foreign keyboards.

(ix) It is said that Hal Snyder of Mark Williams, Co remarked:
"We find that about 10% of cheap no-name keyboards do not work
in scan code set 3".

(x) These days Linux tries to enable Set 3.
This is good for learning a lot about strange keyboards.
It is bad for having a stable system that just works.

<sect>The AT keyboard controller<p>
A user program can talk to the keyboard controller on the motherboard.
The keyboard controller can again talk to the keyboard.
<p>
When a key is pressed the keyboard sends the corresponding
keyboard scancode to the keyboard controller, and the keyboard controller
translates that and interrupts the CPU, allowing the CPU to read the result.
<p>
More detailed: when a key is pressed, the keyboard sends
a start bit (low), followed by 8 data bits for the keyboard scancode
of the key (least significant first), followed by an odd parity bit,
followed by a stop bit (high).
The keyboard controller reads the data and checks the parity.
If incorrect, retransmission is requested. If incorrect again
a parity error is reported.
If the time between request to send and start of transmission is greater
than 15 ms, or if the eleven bits are not received within 2ms,
a timeout is reported.
In both cases (parity error or timeout), the data byte is set to 0xff.
<!-- or 0xfe ? [AMIBIOS] -->
<p>
The keyboard controller has three 8-bit registers involved in
communication with the CPU: its input buffer, that can be written
by the CPU by writing port 0x60 or port 0x64; its output buffer,
that can be read by the CPU by reading from port 0x60; and the
status register, that can be read by the CPU by reading from port 0x64.
<p>
If the CPU writes to port 0x64, the byte is interpreted as a command byte.
If the CPU writes to port 0x60, the byte is interpreted as a data byte.
<p>
The keyboard controller has two 8-bit I/O ports involved in
communication with the keyboard: the
<ref id="inputport" name="input port"> P1 (receiving input from the keyboard)
and the <ref id="outputport" name="output port"> P2 (for sending output
to the keyboard).

<sect1>The keyboard controller status register<p>
The keyboard controller has an 8-bit status register.
It can be inspected by the CPU by reading port 0x64.
<p>
(Typically, it has the value 0x14: keyboard not locked, self-test completed.)
<p>
<table><tabular ca="cccccccc">
<ref id="kcPARE" name="PARE"> |
<ref id="kcTIM" name="TIM"> |
<ref id="kcAUXB" name="AUXB"> |
<ref id="kcKEYL" name="KEYL"> |
<ref id="kcCD" name="C/D"> |
<ref id="kcSYSF" name="SYSF"> |
<ref id="kcINPB" name="INPB"> |
<ref id="kcOUTB" name="OUTB"> @
</tabular></table>
<p>
<it>Bit 7: <label id="kcPARE">Parity error</it><p>
0: OK.
1: Parity error with last byte. <!-- , or last byte was 0xfe. -->
<p>
<it>Bit 6: <label id="kcTIM">Timeout</it><p>
0: OK.
1: Timeout.
On PS/2 systems: General timeout.
On AT systems: Timeout on transmission from keyboard to keyboard controller.
Possibly parity error (in which case both bits 6 and 7 are set).
<p>
<it>Bit 5: <label id="kcAUXB">Auxiliary output buffer full</it><p>
On PS/2 systems:
Bit 0 tells whether a read from port 0x60 will be valid.
If it is valid, this bit 5 tells what data will be read from port 0x60.
0: Keyboard data. 1: Mouse data.
<p>
On AT systems:
0: OK.
1: Timeout on transmission from keyboard controller to keyboard.
This may indicate that no keyboard is present.
<p>
<it>Bit 4: <label id="kcKEYL">Keyboard lock</it><p>
0: Locked.
1: Not locked.
<p>
<it>Bit 3: <label id="kcCD">Command/Data</it><p>
0: Last write to input buffer was data (written via port 0x60).
1: Last write to input buffer was a command (written via port 0x64).
(This bit is also referred to as Address Line A2.)
<p>
<it>Bit 2: <label id="kcSYSF">System flag</it><p>
Set to 0 after power on reset.
Set to 1 after successful completion of the keyboard controller self-test
(Basic Assurance Test, BAT).
Can also be set by command (see <ref id="kccb2" name="below">).
<p>
<it>Bit 1: <label id="kcINPB">Input buffer status</it><p>
0: Input buffer empty, can be written.
1: Input buffer full, don't write yet.
<p>
<it>Bit 0: <label id="kcOUTB">Output buffer status</it><p>
0: Output buffer empty, don't read yet.
1: Output buffer full, can be read.
(In the PS/2 situation bit 5 tells whether the available data is
from keyboard or mouse.)
This bit is cleared when port 0x60 is read.
<p>

<sect1>The keyboard controller command byte<label id="commandbyte"><p>
The keyboard controller is provided with some RAM, for example 32 bytes,
that can be accessed by the CPU. The most important part of this RAM is
byte 0, the Controller Command Byte (CCB). It can be read/written by
writing 0x20/0x60 to port 0x64 and then reading/writing a data byte
from/to port 0x60.
<p>
This byte has the following layout.
<p>
<table><tabular ca="cccccccc">
<ref id="kccb7" name="0"> |
<ref id="kccb6" name="XLATE"> |
<ref id="kccb5" name="ME"> |
<ref id="kccb4" name="KE"> |
<ref id="kccb3" name="IGNLK"> |
<ref id="kccb2" name="SYSF"> |
<ref id="kccb1" name="MIE"> |
<ref id="kccb0" name="KIE"> @
</tabular></table>

<it>Bit 7: <label id="kccb7">Unused</it><p>
Always 0.
<p>
<it>Bit 6: <label id="kccb6">Translate</it><p>
0: No translation.
1: Translate keyboard scancodes, using the
<ref id="translationtable" name="translation table"> given above.
MCA type 2 controllers cannot set this bit to 1. In this case
scan code conversion is set using keyboard command 0xf0 to port 0x60.
<p>
<it>Bit 5: <label id="kccb5">Mouse enable</it><p>
On an EISA or PS/2 system: 0: Enable mouse. 1: Disable mouse
by driving the clock line low.
On an ISA system: "PC Mode": 0: use 11-bit codes, check parity and do
scan conversion.
1: use 8086 codes, don't check parity and don't do scan conversion.
<p>
<it>Bit 4: <label id="kccb4">Keyboard enable</it><p>
0: Enable keyboard. 1: Disable keyboard
by driving the clock line low.
<p>
<it>Bit 3: <label id="kccb3">Ignore keyboard lock</it><p>
For PS/2: Unused, always 0.
For AT:
0: No action. 1: Force <ref id="kcKEYL" name="bit 4"> of the status register
to 1, "not locked". This is used for keyboard testing after power on.
Maybe only on older motherboards.
<p>
<it>Bit 2: <label id="kccb2">System flag</it><p>
This bit is shown in <ref id="kcSYSF" name="bit 2"> of the status register.
A "cold reboot" is one with this bit set to zero.
A "warm reboot" is one with this bit set to one (BAT already completed).
This will influence the tests and initializations done by the POST.
<p>
<it>Bit 1: <label id="kccb1">Mouse interrupt enable</it><p>
On an ISA system: unused, always 0. On an EISA or PS/2 system:
0: Do not use mouse interrupts.
1: Send interrupt request IRQ12 when the mouse output buffer is full.
<p>
<it>Bit 0: <label id="kccb0">Keyboard interrupt enable</it><p>
0: Do not use keyboard interrupts.
1: Send interrupt request IRQ1 when the keyboard output buffer is full.
<p>
When no interrupts are used, the CPU has to poll bits 0 (and 5)
of the status register.

<sect1>Keyboard controller commands<p>
The CPU can command the keyboard controller by writing port 0x64.
Useful, generally available, keyboard commands are:

<p><table><tabular ca="ll">
<ref id="kcc20" name="0x20"> | Read keyboard controller command byte @
<ref id="kcc60" name="0x60"> | Write keyboard controller command byte @
<ref id="kccaa" name="0xaa"> | Self test @
<ref id="kccab" name="0xab"> | Interface test @
<ref id="kccad" name="0xad"> | Disable keyboard @
<ref id="kccae" name="0xae"> | Enable keyboard @
<ref id="kccc0" name="0xc0"> | Read input port @
<ref id="kccd0" name="0xd0"> | Read output port @
<ref id="kccd1" name="0xd1"> | Write output port @
<ref id="kcce0" name="0xe0"> | Read test inputs @
<ref id="kccfe" name="0xfe"> | System reset @
</tabular></table>

Useful, generally available, mouse commands are:

<p><table><tabular ca="ll">
<ref id="kcca7" name="0xa7"> | Disable mouse port @
<ref id="kcca8" name="0xa8"> | Enable mouse port @
<ref id="kcca9" name="0xa9"> | Test mouse port @
<ref id="kccd4" name="0xd4"> | Write to mouse @
</tabular></table>

Obscure, probably obsolete, commands:

<p><table><tabular ca="ll">
<ref id="kcc00" name="0x00-0x1f"> | Read keyboard controller RAM @
<ref id="kcc20" name="0x20-0x3f"> | Read keyboard controller RAM @
<ref id="kcc40" name="0x40-0x5f"> | Write keyboard controller RAM @
<ref id="kcc60" name="0x60-0x7f"> | Write keyboard controller RAM @
<ref id="kcca0" name="0xa0"> | Read copyright @
<ref id="kcca1" name="0xa1"> | Read firmware version @
<ref id="kcca2" name="0xa2"> | Switch speed @
<ref id="kcca3" name="0xa3"> | Switch speed @
<ref id="kcca4" name="0xa4"> | Check if password installed @
<ref id="kcca5" name="0xa5"> | Load password @
<ref id="kcca6" name="0xa6"> | Check password @
<ref id="kccac" name="0xac"> | Diagnostic dump @
<ref id="kccaf" name="0xaf"> | Read keyboard version @
<ref id="kccb0" name="0xb0-0xb5"> | Reset keyboard controller line @
<ref id="kccb8" name="0xb8-0xbd"> | Set keyboard controller line @
<ref id="kccc1" name="0xc1"> | Continuous input port poll, low @
<ref id="kccc2" name="0xc2"> | Continuous input port poll, high @
<ref id="kccc8" name="0xc8"> | Unblock lines P22 and P23 @
<ref id="kccc9" name="0xc9"> | Block lines P22 and P23 @
<ref id="kccca" name="0xca"> | Read keyboard controller mode @
<ref id="kcccb" name="0xcb"> | Write keyboard controller mode @
<ref id="kccd2" name="0xd2"> | Write keyboard output buffer @
<ref id="kccd3" name="0xd3"> | Write mouse output buffer @
<ref id="kccdd" name="0xdd"> | Disable A20 address line @
<ref id="kccdf" name="0xdf"> | Enable A20 address line @
<ref id="kccf0" name="0xf0-0xff"> | Pulse output bit @
</tabular></table>

<it>Command 0x00-0x1f: <label id="kcc00">Read keyboard controller RAM</it><p>
(AMIBIOS only) Aliases for 0x20-0x3f.

<it>Command 0x20-0x3f: <label id="kcc20">Read keyboard controller RAM</it><p>
The last six bits of the command specify the RAM address to read.
The read data is placed into the output buffer, and can be read
by reading port 0x60.
On MCA systems, type 1 controllers can access all 32 locations;
type 2 controllers can only access locations 0, 0x13-0x17, 0x1d, 0x1f.
<p>
Location 0 is the <ref id="commandbyte" name="Command byte">, see above.
<p>
Location 0x13 (on MCA) is nonzero when a password is enabled.
<p>
Location 0x14 (on MCA) is nonzero when the password was matched.
<p>
Locations 0x16-0x17 (on MCA) give two make codes to be discarded
during password matching.

<it>Command 0x40-0x5f: <label id="kcc40">Write keyboard controller RAM</it><p>
(AMIBIOS only) Aliases for 0x40-0x5f.

<it>Command 0x60-0x7f: <label id="kcc60">Write keyboard controller RAM</it><p>

<!-- VIA: 0x9*: write low nibble to Port13-Port10 -->

<it>Command 0xa0: <label id="kcca0">Read copyright</it><p>
On some keyboard controllers: an ASCIZ copyright string
(possibly just NUL) is made available for reading via port 0x60.
On other systems: no effect, the command is ignored.
<p>

<it>Command 0xa1: <label id="kcca1">Read controller firmware version</it><p>
On some keyboard controllers: a single ASCII byte is made available
for reading via port 0x60.
<!-- Via, AMI BIOS -->
<!-- I read 0x48 -->
On other systems: no effect, the command is ignored.
<p>

<it>Command 0xa2: <label id="kcca2">Switch speed</it><p>
(On ISA/EISA systems with AMI BIOS)
Reset keyboard controller lines P22 and P23 low.
These lines can be used for speed switching via the keyboard controller.
When done, the keyboard controller sends one garbage byte to the system.
<p>

<it>Command 0xa3: <label id="kcca3">Switch speed</it><p>
(On ISA/EISA systems with AMI BIOS)
Set keyboard controller lines P22 and P23 high.
These lines can be used for speed switching via the keyboard controller.
When done, the keyboard controller sends one garbage byte to the system.
<p>
(Compaq BIOS: Enable system speed control.)

<it>Command 0xa4: <label id="kcca4">Check if password installed</it><p>
On MCA systems:
Return 0xf1 (via port 0x60) when no password is installed,
return 0xfa when a password has been installed.
Some systems without password facility always return 0xf1.
<!-- e.g., VIA -->
<p>
(On ISA/EISA systems with AMI BIOS)
Write Clock = Low.
<p>
(Compaq BIOS: toggle speed.)
<p>

<it>Command 0xa5: <label id="kcca5">Load password</it><p>
On MCA systems:
Load a password by writing a NUL-terminated string to port 0x60.
The string is in scancode format.
<p>
(On ISA/EISA systems with AMI BIOS)
Write Clock = High.
<p>
(Compaq BIOS: special read of P2, with bits 4 and 5 replaced:
Bit 5: 0: 9-bit keyboard, 1: 11-bit keyboard.
Bit 4: 0: outp-buff-full interrupt disabled, 1: enabled.)
<p>

<it>Command 0xa6: <label id="kcca6">Check password</it><p>
On MCA systems:
When a password is installed:
Check password by matching keystrokes with the stored password.
Enable keyboard upon successful match.
<p>
(On ISA/EISA systems with AMI BIOS)
Read Clock. 0: Low. 1: High.
<p>

<it>Command 0xa7: <label id="kcca7">Disable mouse port</it><p>
On MCA systems: disable the mouse (auxiliary device)
by setting its clock line low, and set <ref id="kccb5" name="bit 5">
of the <ref id="commandbyte" name="Command byte">. Now P23 = 1.
<p>
(On ISA/EISA systems with AMI BIOS)
Write Cache Bad.
<p>

<it>Command 0xa8: <label id="kcca8">Enable mouse port</it><p>
On MCA systems: enable the mouse (auxiliary device),
clear <ref id="kccb5" name="bit 5"> of the
<ref id="commandbyte" name="Command byte">. Now P23 = 0.
<p>
(On ISA/EISA systems with AMI BIOS)
Write Cache Good.
<p>

<it>Command 0xa9: <label id="kcca9">Test mouse port</it><p>
On MCA and other systems: test the serial link between
keyboard controller and mouse. The result can be read from port 0x60.
0: OK.
1: Mouse clock line stuck low.
2: Mouse clock line stuck high.
3: Mouse data line stuck low.
4: Mouse data line stuck high.
0xff: No mouse.
<p>
(On ISA/EISA systems with AMI BIOS)
Read Cache Bad or Good. 0: Bad. 1: Good.

<it>Command 0xaa: <label id="kccaa">Self test</it><p>
Perform self-test. Return 0x55 if OK, 0xfc if NOK.

<it>Command 0xab: <label id="kccab">Interface test</it><p>
Test the serial link between keyboard controller and keyboard.
The result can be read from port 0x60.
0: OK.
1: Keyboard clock line stuck low.
2: Keyboard clock line stuck high.
3: Keyboard data line stuck low.
4: Keyboard data line stuck high.
0xff: General error.
<p>

<it>Command 0xac: <label id="kccac">Diagnostic dump</it><p>
(On some systems)
Read from port 0x60 sixteen bytes of keyboard controller RAM,
and the output and input ports and the controller's program status word.
<p>

<it>Command 0xad: <label id="kccad">Disable keyboard</it><p>
Disable the keyboard clock line and set <ref id="kccb5" name="bit 4">
of the <ref id="commandbyte" name="Command byte">.
Any keyboard command enables the keyboard again.
<p>

<it>Command 0xae: <label id="kccae">Enable keyboard</it><p>
Enable the keyboard clock line and clear <ref id="kccb5" name="bit 4">
of the <ref id="commandbyte" name="Command byte">.
<p>

<it>Command 0xaf: <label id="kccaf">Read keyboard version</it><p>
(Award BIOS, VIA)

<it>Command 0xb0-0xb5,0xb8-0xbd:
<label id="kccb0"><label id="kccb8">Reset/set keyboard controller line</it><p>
AMI BIOS:
Commands 0xb0-0xb5 reset a keyboard controller line low.
Commands 0xb8-0xbd set the corresponding keyboard controller line high.
The lines are P10, P11, P12, P13, P22 and P23, respectively.
(In the case of the lines P10, P11, P22, P23 this is on ISA/EISA systems only.)
When done, the keyboard controller sends one garbage byte to the system.
<p>
VIA BIOS:
Commands 0xb0-0xb7 write 0 to lines P10, P11, P12, P13, P22, P23, P14, P15.
Commands 0xb8-0xbf write 1 to lines P10, P11, P12, P13, P22, P23, P14, P15.
<p>

<it>Command 0xc0: <label id="kccc0">Read input port</it><p>
Read the <ref id="inputport" name="input port"> (P1),
and make the resulting byte available to be read from port 0x60.
<p>

<it>Command 0xc1: <label id="kccc1">Continuous input port poll, low</it><p>
(MCA systems with type 1 controller only)
Continuously copy bits 3-0 of the input port to be read from bits 7-4
of port 0x64, until another keyboard controller command is received.
<!-- AMI docs call this command 0xc3. -->
<!-- VIA: copy bits 3-1 to bits 7-5 -->
<p>

<it>Command 0xc2: <label id="kccc2">Continuous input port poll, high</it><p>
(MCA systems with type 1 controller only)
Continuously copy bits 7-4 of the input port to be read from bits 7-4
of port 0x64, until another keyboard controller command is received.
<!-- VIA: copy bits 7-5 to bits 7-5 -->
<p>

<it>Command 0xc8:
<label id="kccc8">Unblock keyboard controller lines P22 and P23</it><p>
(On ISA/EISA systems with AMI BIOS)
After this command, the system can make lines P22 and P23 low/high
using <ref id="kccd1" name="command 0xd1">.
<p>

<it>Command 0xc9:
<label id="kccc9">Block keyboard controller lines P22 and P23</it><p>
(On ISA/EISA systems with AMI BIOS)
After this command, the system cannot make lines P22 and P23 low/high
using <ref id="kccd1" name="command 0xd1">.
<p>

<it>Command 0xca: <label id="kccca">Read keyboard controller mode</it><p>
(AMI BIOS, VIA)
Read keyboard controller mode to bit 0 of port 0x60.
0: ISA (AT) interface.
1: PS/2 (MCA)interface.
<p>

<it>Command 0xcb: <label id="kcccb">Write keyboard controller mode</it><p>
(AMI BIOS)
Write keyboard controller mode to bit 0 of port 0x60.
0: ISA (AT) interface.
1: PS/2 (MCA)interface.
(First read the mode using command 0xca, then modify only
the last bit, then write the mode using this command.)
<p>

<it>Command 0xd0: <label id="kccd0">Read output port</it><p>
Read the <ref id="outputport" name="output port"> (P2)
and place the result in the output buffer.
Use only when output buffer is empty.
<p>

<it>Command 0xd1: <label id="kccd1">Write output port</it><p>
Write the <ref id="outputport" name="output port"> (P2).
Note that writing a 0 in bit 0 will cause a hardware reset.
<p>
(Compaq: the system speed bits are not set. Use commands 0xa1-0xa6 for that.)
<p>

<it>Command 0xd2: <label id="kccd2">Write keyboard output buffer</it><p>
(MCA)
Write the keyboard controllers output buffer with the byte
next written to port 0x60, and act as if this was keyboard data.
(In particular, raise IRQ1 when <ref id="kccb0" name="bit 0">
of the <ref id="commandbyte" name="Command byte"> says so.)
<p>

<it>Command 0xd3: <label id="kccd3">Write mouse output buffer</it><p>
(MCA)
Write the keyboard controllers output buffer with the byte
next written to port 0x60, and act as if this was mouse data.
(In particular, raise IRQ12 when <ref id="kccb1" name="bit 1">
of the <ref id="commandbyte" name="Command byte"> says so.)
<p>

<it>Command 0xd4: <label id="kccd4">Write to mouse</it><p>
(MCA)
The byte next written to port 0x60 is transmitted to the mouse.
<p>

<it>Command 0xdd: <label id="kccdd">Disable A20 address line</it><p>
(HP Vectra)
<p>

<it>Command 0xdf: <label id="kccdf">Enable A20 address line</it><p>
(HP Vectra)
<p>

<it>Command 0xe0: <label id="kcce0">Read test inputs</it><p>
This command makes the status of the
<ref id="testinputs" name="Test inputs"> T0 and T1 available
to be read via port 0x60 in bits 0 and 1, respectively.
Use only when the output port is empty.
<p>

<!-- VIA: 0xe*: P23-P21 will change according to the status on bit3-1 -->

<it>Command 0xf0-0xff: <label id="kccf0">Pulse output bit</it><p>
Bits 3-0 of the <ref id="outputport" name="output port"> P2
of the keyboard controller may be pulsed low for approximately 6 µseconds.
Bits 3-0 of this command specify the output port bits to be pulsed.
0: Bit should be pulsed.
1: Bit should not be modified. 
The only useful version of this command is Command 0xfe.
(For MCA, replace 3-0 by 1-0 in the above.)
<p>

<it>Command 0xfe: <label id="kccfe">System reset</it><p>
Pulse bit 0 of the <ref id="outputport" name="output port"> P2
of the keyboard controller. This will reset the CPU.
<p>

<sect1>The input port P1<label id="inputport"><p>
This has the following layout.
<p>
<table><tabular ca="ccc">
bit 7 | Keyboard lock    | 0: locked, 1: not locked @
bit 6 | Display          | 0: CGA, 1: MDA @
bit 5 | Manufacturing jumper | 0: installed, 1: not installed @
      |            | with jumper the BIOS runs an infinite diagnostic loop @
bit 4 | RAM on motherboard | 0: 512 KB, 1: 256 KB @
<!-- AMI BIOS says: 0: 256 KB, 1: 512 KB or more -->
<!-- w83c43, 42w11 say: 0: disable second 256 KB, 1: enable second 256 KB -->
bit 3 | &nbsp;           | Unused in ISA, EISA, PS/2 systems @
      | &nbsp;           | Can be configured for clock switching @
bit 2 | &nbsp;           | Unused in ISA, EISA, PS/2 systems @
      | &nbsp;           | Can be configured for clock switching @
      | Keyboard power   | PS/2 MCA: 0: keyboard power normal, 1: no power @
bit 1 | Mouse data in    | Unused in ISA @
bit 0 | Keyboard data in | Unused in ISA @
</tabular></table>

Clearly only bits 1-0 are input bits.
Of the above, the original IBM AT used bits 7-4, while PS/2 MCA systems
use only bits 2-0.

Where in the above lines P10, P11, etc are used, these refer to the pins
corresponding to bit 0, bit 1, etc of port P1.

<sect1>The output port P2<label id="outputport"><p>
This has the following layout.
<p>
<table><tabular ca="ccc">
bit 7 | Keyboard data | data to keyboard @
bit 6 | Keyboard clock @
bit 5 | IRQ12         | 0: IRQ12 not active, 1: active @
bit 4 | IRQ1          | 0: IRQ1 not active, 1: active @
<!-- w83c43: (AT) bit 4: output buffer full, bit 5: input buffer empty -->
bit 3 | Mouse clock   | Unused in ISA @
bit 2 | Mouse data    | Unused in ISA. Data to mouse @
bit 1 | A20           | 0: A20 line is forced 0, 1: A20 enabled @
bit 0 | Reset         | 0: reset CPU, 1: normal @
</tabular></table>

Where in the above lines P20, P21, etc are used, these refer to the pins
corresponding to bit 0, bit 1, etc of port P2.

<sect1>The test port T<label id="testinputs"><p>
<it>bit 0</it><p>
Keyboard clock (input).

<it>bit 1</it><p>
(AT) Keyboard data (input).
(PS/2) Mouse clock (input).

<sect>USB<p>
The USB specification prescribes 16-bit keycodes for keyboard positions,
identified with key captions for the usual US layout.
Below the values are given in decimal. 0-3 are protocol values,
namely NoEvent, ErrorRollOver, POSTFail, ErrorUndefined, respectively.
The values 224-231 are for modifier keys.

<p><table><tabular ca="cccccccccccc">
  |   1 |   2 |   3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 @
- | err | err | err | A | B | C | D | E | F |  G |  H @@
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 @
 I |  J |  K |  L |  M |  N |  O |  P |  Q |  R |  S |  T @@
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 @
 U |  V |  W |  X |  Y |  Z |  1 |  2 |  3 |  4 |  5 |  6 @@
36 | 37 | 38 | 39 |   40  |  41 |  42 |  43 |   44  |  45 | 46 | 47 @
 7 |  8 |  9 |  0 | Enter | Esc | BSp | Tab | Space | - / &lowbar; | = / + | &lsqb; / { @@
    48     |   49         |   50  |    51    |   52  |   53        |
    54     |   55         |   56  |    57    |   58  |   59        @
&rsqb; / } | \ / &verbar; |   ... |   ; / :  | ' / " | ` / &tilde; |
  , / &lt; | . / &gt;     | / / ? | Caps Lock |   F1  |   F2 @@
60 | 61 | 62 | 63 | 64 | 65 | 66 |  67 |  68 |  69 |   70   | 71      @
F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | PrtScr | Scroll Lock @@
  72  |   73   |  74  |  75  |   76   |   77     |
  78  |   79   |  80  |  81  |   82   |   83     @
Pause | Insert | Home | PgUp | Delete |   End    |
 PgDn |  Right | Left | Down |   Up   | Num Lock @@
     84     |     85      |      86     |  87  |      88      |     89     |
     90     |     91      |      92     |  93  |      94      |     95     @
    KP /    |    KP *     |     KP -    | KP + |   KP Enter   | KP 1 / End |
KP 2 / Down | KP 3 / PgDn | KP 4 / Left | KP 5 | KP 6 / Right | KP 7 / Home @@
     96   |      97     |     98     |     99     | 100 |   101  |
    102   |     103     |    104     |    105     | 106 |   107  @
KP 8 / Up | KP 9 / PgUp | KP 0 / Ins | KP . / Del | ... | Applic |
  Power   |    KP =     |    F13     |    F14     | F15 |   F16  @@
108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 |   116   |  117 |  118 |   119 @
F17 | F18 | F19 | F20 | F21 | F22 | F23 | F24 | Execute | Help | Menu | Select @@
 120 |   121 |     122   |     123     |         124       |        125       |
 126 |   127 |     128   |     129     |         130       |        131       @
Stop | Again |    Undo   |     Cut     |        Copy       |       Paste      |
Find |  Mute | Volume Up | Volume Down | Locking Caps Lock | Locking Num Lock @@
         132        |  133 |  134 |   135    | 136 | 137 |
         138        |  139 |  140 |   141    | 142 | 143 @
Locking Scroll Lock | KP , | KP = | Internat | Internat | Internat |
         Internat        |  Internat |  Internat |   Internat    | Internat | Internat @@
 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 |    153    |  154  |   155  @
LANG | LANG | LANG | LANG | LANG | LANG | LANG | LANG | LANG | Alt Erase | SysRq | Cancel @@
 156  |  157  |   158  |  159  | 160 |  161 |     162       |     163       | 164 |165|166|167 @
Clear | Prior | Return | Separ | Out | Oper | Clear / Again | CrSel / Props | ExSel | | @@@
 224  |   225  |  226 |  227 |  228  |   229  |  230 |  231 @
LCtrl | LShift | LAlt | LGUI | RCtrl | RShift | RAlt | RGUI @@
</tabular></table>

<sect>Reporting<p>
Additions and corrections are welcome.
Use <tt>showkey -s</tt> to get the scancodes.
Mention keyboard manufacturer and type, and the keycaps.
<p>
Andries Brouwer - <tt/aeb@cwi.nl/

</article>
