IBM PC AT Keyboard Protocol - mcaple/tmk_keyboard GitHub Wiki

Technical Reference

Protocol

Host reads/sends data on falling edges of clock.

Signaling:
        ____            ____
    CLK H       L___    H
        ____    ____ 
    DAT H       H       L___
        Idle    inHibit Request-to-send

Keyboard to Host:
        ____ 1 _ 2 _ 3 _ 4 _ 5 _ 6 _ 7 _ 8 _ 9 _ A _ B _____     _ B
    CLK     \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/         / \_____
        ___     ___ ___ ___ ___ ___ ___ ___ ___ ___ ________    _ ______
    DAT    \___/___X___X___X___X___X___X___X___X___/            _/
             S   0   1   2   3   4   5   6   7   P   s             s  H
                                                                Inhibit by host on error  
        
Host to Keyboard:
        __      _ 1 _ 2 _ 3 _ 4 _ 5 _ 6 _ 7 _ 8 _ 9 _ A __ B ____
    CLK   \____/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/  \_/
        ______     ___ ___ ___ ___ ___ ___ ___ ___ ______     ____
    DAT       \___/___X___X___X___X___X___X___X___X___/  \___/
           H    R   0   1   2   3   4   5   6   7   P   s ACK

Clock and Data Signals

p.212 http://bitsavers.org/pdf/ibm/pc/at/6183355_PC_AT_Technical_Reference_Mar86.pdf

p.4-27 http://bitsavers.trailing-edge.com/pdf/ibm/pc/industrial_computer/6522361_IBM_7531_7532_Industrial_Computer_Technical_Reference_System_Unit_Jul85.pdf

The keyboard and system communicate over the 'clock' and 'data' lines. The source of each of these lines is an open-collector device on the keyboard that allows either the keyboard or the system to force a line to an inactive (low) level. When no communication is occurring, the 'clock' line is at an active (high) level. The state of the 'data' line is held active(high) by the keyboard. When the system sends data to the keyboard, it forces the 'data' line to an inactive level and allows the 'clock' line to go to an active level. An inactive signal will have a value of at least 0, but not greater than +0.7 volts. A signal at the inactive level is a logical O. An active signal will have a value of at least +2.4, but not greater than +5.5 volts. A signal at the active level is a logical 1. Voltages are measured between a signal source and the dc network ground. The keyboard 'clock' line provides the clocking signals used to clock serial data to and from the keyboard. If the host system forces the 'clock' line to an inactive level, keyboard transmission is inhibited. When the keyboard sends data to, or receives data from the system, it generates the 'clock' signal to time the data. The system can prevent the keyboard from sending data by forcing the 'clock' line to an inactive level; the 'data' line may be active or inactive during this time. During the BAT, the keyboard allows the 'clock' and 'data' lines to go to an active level.

Data Stream

Data transmissions to and from the keyboard consist of an 11-bit data stream (Mode 2) sent serially over the 'data' line. A logical 1 is sent at an active (high) level. The following table shows the functions of the bits.

Bit Function
1 Start bit (always 0)
2 Data bit 0 (least-significant)
3 Data bit 1
4 Data bit 2
5 Data bit 3
6 Data bit 4
7 Data bit 5
8 Data bit 6
9 Data bit 7 (most-significant)
10 Parity bit (odd parity)
11 Stop bit (always 1)

The parity bit is either 1 or 0, and the 8 data bits, plus the parity bit, always have an odd number of 1 's.

Note: Mode 1 is a 9-bit data stream that does not have a parity bit or stop bit and the start bit is always 1.

Keyboard Data Output

When the keyboard is ready to send data, it first checks for a keyboard-inhibit or system request-to-send status on the 'clock' and 'data' lines. If the 'clock' line is inactive (low), data is stored in the keyboard buffer. If the 'clock' line is active (high) and the 'data' line is inactive (request-to-send), data is stored in the keyboard buffer, and the keyboard receives system data. If the 'clock' and 'data' lines are both active, the keyboard sends the 0 start bit, 8 data bits, the parity bit, and the stop bit. Data will be valid before the trailing edge and beyond the leading edge of the clock pulse. During transmission, the keyboard checks the 'clock' line for an active level at least every 60 milliseconds. If the system lowers the 'clock' line from an active level after the keyboard starts sending data, a condition known as line contention occurs, and the keyboard stops sending data. If line contention occurs before the leading edge of the 10th clock signal (parity bit), the keyboard buffer returns the 'clock' and 'data' lines to an active level. If contention does not occur by the 10th clock signal, the keyboard completes the transmission. Following line contention, the system mayor may not request the keyboard to resend the data. Following a transmission, the system can inhibit the keyboard until the system processes the input, or until it requests that a response be sent.

Keyboard Data Input

When the system is ready to send data to the keyboard, it first checks to see if the keyboard is sending data. If the keyboard is sending, but has not reached the 10th 'clock' signal, the system can override the keyboard output by forcing the keyboard 'clock' line to an inactive (low) level. If the keyboard transmission is beyond the 10th 'clock' signal, the system must receive the transmission. If the keyboard is not sending, or if the system elects to override the keyboard's output, the system forces the keyboard 'clock' line to an inactive level for more than 60 microseconds while preparing to send data. When the system is ready to send the start bit (the 'data' line will be inactive), it allows the 'clock' line to go to an active (high) level. The keyboard checks the state of the' clock' line at intervals of no more than 10 milliseconds. If a system request-to-send (RTS) is detected, the keyboard counts 11 bits. After the 10th bit, the keyboard checks for an active level on the 'data' line, and if the line is active, forces it inactive, and counts one more bit. This action signals the system that the keyboard has received its data. Upon receipt of this signal, the system returns to a ready state, in which it can accept keyboard output, or goes to the inhibited state until it is ready.

If the keyboard 'data' line is found at an inactive level following the 10th bit, a framing error has occurred, and the keyboard continues to count until the 'data' line becomes active. The keyboard then makes the 'data' line inactive and sends a Resend. Each system command or data transmission to the keyboard requires a response from the keyboard before the system can send its next output. The keyboard will respond within 20 milliseconds unless the system prevents keyboard output. If the keyboard response is invalid or has a parity error, the system sends the command or data again. However, the two byte commands require special handling. If hex F3 (Set Typematic Rate/Delay), hex F0 (Select Alternate Scan Codes), or hex ED (Set/Reset Mode Indicators) have been sent and acknowledged, and the value byte has been sent but the response is invalid or has a parity error, the system will resend both the command and the value byte.

i8042 Keyboard Controller on Host

PC/AT: http://halicery.com/8042/8042_1503033.TXT

PS/2: http://www.halicery.com/Hardware/Intel%208042%20and%208048/8042_PS2_INTERN.TEXT

Stop bit of Data Output

IBM AT(and PS/2) keyboard controller checks data line only, not clock for Stop bit.(03C0:)

ACK of Data Input

IBM AT(and PS/2) keyboard controller checks data line only, not clock for ACK. (0274:) (026C:)

0268: F0      MOV A,@R0     ; send Stop bit..
0269: 62      MOV T,A
026A: 55      STRT T
026B: 26 6B   JNT0 $026B    ; wait for Clock Hi
026D: 44 6F   JMP $026F
026F: 36 6F   JT0 $026F     ; wait for Clock Lo
0271: 8A 80   ORL P2,#$80   ; P27: Data Hi
0273: 65      STOP TCNT

0274: F0      MOV A,@R0     ; Wait for |_| on DATA (ACK)..
0275: 62      MOV T,A
0276: 55      STRT T
0277: 56 77   JT1 $0277    ; wait for Data Lo
0279: 44 7B   JMP $027B
027B: 46 7B   JNT1 $027B   ; wiat for Data Hi
027D: 65      STOP TCNT

Waveform

IBM 1394100 Terminal

0x15(Q make):

0xF0:

https://geekhack.org/index.php?topic=62168.msg1469247#msg1469247

kbdbabel.org

http://www.kbdbabel.org/

TechRef

http://www.mcamafia.de/pdf/ibm_hitrc07.pdf

Zenith Z-150 beige

0xAA(BAT OK):

Note that stop bit is low and this is clearly violation of IBM AT protocol.

https://geekhack.org/index.php?topic=103648.msg2895701#msg2895701

Receiving Data  
    IBM AT:
        ____ 1 _ 2 _ 3 _ 4 _ 5 _ 6 _ 7 _ 8 _ 9 _ A _ B _____
    CLK     \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
        ___     ___ ___ ___ ___ ___ ___ ___ ___ ___ ________
    DAT    \___/___X___X___X___X___X___X___X___X___/
             S   0   1   2   3   4   5   6   7   P   s

    Z-150 AT:
        ____ 1 _ 2 _ 3 _ 4 _ 5 _ 6 _ 7 _ 8 _ 9 _ A _ B _____  
    CLK     \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/  
        ___     ___ ___ ___ ___ ___ ___ ___ ___ ___     ___
    DAT    \___/___X___X___X___X___X___X___X___X___\___/
             S   0   1   2   3   4   5   6   7   P   s*
    * Stop bit is Lo(0) 
    
Sending Data
    IBM AT:   
        __      _ 1 _ 2 _ 3 _ 4 _ 5 _ 6 _ 7 _ 8 _ 9 _ A __ B ____
    CLK   \____/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/  \_/
        ______     ___ ___ ___ ___ ___ ___ ___ ___ ______     ____
    DAT       \___/___X___X___X___X___X___X___X___X___/  \___/
           H    R   0   1   2   3   4   5   6   7   P   s ACK

    Z-150 AT:
        __      _ 1 _ 2 _ 3 _ 4 _ 5 _ 6 _ 7 _ 8 _ 9 _ A ________
    CLK   \____/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ XXXXX
        ______     ___ ___ ___ ___ ___ ___ ___ ___ ______     ____
    DAT       \___/___X___X___X___X___X___X___X___X___/  \___/
           H    R   0   1   2   3   4   5   6   7   P   s ACK*

    * No or slow clock pulse for ACK(Not confirmed).

See this for error when sending command. https://github.com/tmk/tmk_keyboard/issues/661

Commands from the System

The commands may be sent to the keyboard at any time. The keyboard will respond within 20 milliseconds, except when performing the basic assurance test (BAT), or executing a Reset command.

p158(4-7), p.191(4-40) of http://bitsavers.org/pdf/ibm/pc/at/6183355_PC_AT_Technical_Reference_Mar86.pdf

Command Hex Value
Set/Reset Status Indicators* ED
Echo* EE
Select Alternate Scan Codes F0
Read ID F2
Set Typematic Reate/Delay* F3
Enable* F4
Default Disable* F5
Set Default* F6
Set All Keys - Typematic F7
Set All Keys - Make/Break F8
Set All Keys - Make F9
Set All Keys - Typematic/Make/Break FA
Set Key Type - Typematic FB
Set Key Type - Make/Break FC
Set Key Type - Make FD
Resend* FE
Reset* FF

*: 84-key supports only these commands

Set/Reset Status Indicators(ED)

Bit Indicator
0 Scroll Lock
1 Num Lock
2 Caps Lock

Select Alternate Scan Codes(F0)

Tested F0 command with some keyboards. IBM 122-key doesn't support F0 commad at all. Cherry supports Set 2 and 3 while SKIDATA supports all 3 sets.

keyboard F0 00 F0 01 F0 02 F0 03
IBM 122-key 6110345 FE FE FE FE FE FE FE FE
Cherry G80-3600 FA FA 02 FA FE FA FA FA FA
SKIDATA2-DE FA FA 02 FA FA FA FA FA FA
Cherry G80-2551 ? ? ? FA FA

It seems SKIDATA stores 'Code Set' setting in nonvoliatile memory beyond power cycles until 'FF' reset command is received. Reset command restores to default Code Set 2.

https://geekhack.org/index.php?topic=103648.msg2894921#msg2894921

Commands to the System

p.163(4-12) of http://bitsavers.org/pdf/ibm/pc/at/6183355_PC_AT_Technical_Reference_Mar86.pdf

Command Hex Value
ACK FA
BAT Completion AA
Break Code Prefix F0
BAT Failure FC
Echo Response EE
Resend FE
Keyboard ID 83AB
Key Detection Error 00(scan code set 2 and 3) FF(sacn code set 1)
Overrun 00(scan code set 2 and 3) FF(scan code set 1)

Error handling

When keyboard response to command and data from host has parity or other error, Resend(FE) should net be sent.

If the keyboard response is invalid or has a parity error, the system sends the command or data again.

When host receives data with prirty error, host sends Resend(FE) command.

http://halicery.com/8042/8042_1503033.TXT 0160:

Keyboard ID

AT keyboard can accept 'read keyboard ID' F2 command and replies with ACK FA and 2-byte ID then. XT keyboard doesn't support the command at all.

https://www.win.tue.nl/~aeb/linux/kbd/scancodes-10.html#keyboardid

IBM AT 84-key

When sent an identify command (0xF2), the keyboard responds only with 0xFA (acknowledge). https://www.seasip.info/VintagePC/ibm_6450225.html

But it doesn't response with ID atfter receiving the command.

AB83

Most of PS/2 Keyboards has this ID.

  • Cherry G80-3600
  • Cherry G84-4100
  • Topre Realforce 101 ML0100

AB84

Many short keyboards, like IBM ThinkPads, and Spacesaver keyboards

AB85

NCD N-97

It speaks in Code Set 3. https://www.win.tue.nl/~aeb/linux/kbd/scancodes-7.html#NCD97

IBM 122-key Model M 1393656

https://deskthority.net/viewtopic.php?p=308583#p308583

AB86

Cherry G80-2551 126-key terminal keyboard

It sends scan codes in Set 2 by default and can be switched to Set 3.

https://deskthority.net/wiki/Cherry_G80-2551

https://geekhack.org/index.php?topic=103648.msg2893404#msg2893404

IBM 1397000 Keyboard

http://www.seasip.info/VintagePC/ibm_1397000.html

The Affirmative 1227T Keyboard

http://www.seasip.info/Misc/1227T.html

Unicomp UB40856

https://geekhack.org/index.php?topic=17458.msg648235#msg648235

Other 122-key keyboards

Several 122-key keyboards are reported to send ab 86. Here translated and untranslated values coincide. (Reports mention "122-Key Enhanced Keyboard", "standard 122-key keyboard", "122 Key Mainframe Interactive (MFI) Keyboard", "122-Key Host Connected Keyboard".)

https://www.win.tue.nl/~aeb/linux/kbd/scancodes-10.html#keyboardid

AB90

IBM 5576-002 KEYBOARD-2, part number 94X1110

This Japanese keyboard can be switched to Code Set 3. https://www.win.tue.nl/~aeb/linux/kbd/scancodes-8.html#bradford

http://radioc.web.fc2.com/column/ps55/ps55kbd_scancode.htm

AB91

IBM 5576-003

http://radioc.web.fc2.com/column/ps55/ps55kbd_scancode.htm

AB92

IBM 5576-001

Code Set 2 is only supported. Code Set 2 by default and Code Set 3 and 82h also are supported at least.

https://github.com/tmk/tmk_keyboard/issues/685#issuecomment-850741943

http://radioc.web.fc2.com/column/ps55/ps55kbd_scancode.htm

BFBF

IBM Terminal Keyboards(Code Set 3)

ID can be configured with DIP swithes or pins. http://www.seasip.info/VintagePC/ibm_1390876.html http://www.seasip.info/VintagePC/ibm_6110344.html

7F7F

IBM Terminal 101 1394204

https://github.com/tmk/tmk_keyboard/issues/687

https://user-images.githubusercontent.com/7271421/120397187-1f8f4500-c338-11eb-935e-376645d7354b.jpg

It doesn't seem to be configurable of keyboard ID.

https://user-images.githubusercontent.com/7271421/120395902-0f766600-c336-11eb-9fc2-607a3a43a558.jpeg

It doesn't support F0 command and always uses Code Set 3.

https://github.com/tmk/tmk_keyboard/issues/687#issuecomment-852610160

BFB0

IBM RT Keyboard(Code Set 3)

https://deskthority.net/viewtopic.php?p=105422#p105422

It takes long to response commands and its num lock and caps lock LEDs are swapped.

https://deskthority.net/viewtopic.php?p=105161#p105161

There is Technical Reference on bitsavers.org. http://bitsavers.org/pdf/ibm/pc/rt/75X0232_RT_PC_Technical_Reference_Volume_1_Jun87.pdf

Command F2 and ED(p.9-5):

Command Description
F2 Read ID: Respond with X'BFBO'.
ED Set LED indicator: The LED indicators are set according to bits 5, 6, 7 of the subsequent byte.
Bit LED
5 Num lock
6 Caps lock
7 Scroll lock

00

All PS/2 Mouses send AA 00 at startup and responds with one-byte 00 to F2 command.

Microsoft IntelliMouse and ExplorerMouse respods with id 03 and 04 respectively after proprietary intialization command sequence.

Keyboard ID configuration

IBM 1389160 122 Key Terminal Keyboard

DIP Switch: 0100 0000(~0xBF) pic

https://www.recycledgoods.com/ibm-1389160-122-key-terminal-keyboard-5-pin-din-model-m/

IBM 1389162

https://imgur.com/a/tIonH

DIP Switch: 0111 1110(~0x81?): https://i.imgur.com/hRaltjN.jpg

How DIP Switch wired to controller: https://i.imgur.com/15r5gav.jpg?1

IBM 1390413

https://deskthority.net/viewtopic.php?f=62&t=14734

DIP Switch: 1001 0000(~0x6F?): https://deskthority.net/download/file.php?id=33588

IBM 6110668 - Terminal Model F

DIP Switch: 0000 0000

https://www.flickr.com/photos/triplehaata/sets/72157662296508556/

IBM 1390876

When sent an identify command (0xF2), the keyboard returns the byte sequence 0xBF 0xBF. However, this can be changed. On the keyboard PCB is a 12-pin header, marked as 6 pairs of pins (B2-B7). These correspond to bits 5-0 of the second byte of the keyboard ID. Shorting a pair of pins sets that bit to zero. So placing a jumper on the B2 pair will change the keyboard ID to 0xBF 0x9F.

Adjacent to this header is a space on the circuit board for an identical header, marked as pins A2-A7. Presumably these would have the same effect on the first byte of the keyboard ID.

http://www.seasip.info/VintagePC/ibm_1390876.html#Identity

IBM 6110344

DIP Switch: 0000 0000

The keyboard has eight DIP switches. According to the guide to operations, they should be ignored. If you do change them, they change bits in the keyboard ID (returned by command 0xF2). If all switches are left open (or disconnected) the ID returned is 0xBF 0xBF. Closing a switch sets the corresponding bit to 0.

Switches 1-6 correspond to bits 5-0 of the first ID byte. Switches 7-8 correspond to bits 5-4 of the second ID byte. The header on the controller PCB, to which the DIP switches are connected, has 12 pairs of pins and is silkscreened "KBDID A" (on the first 6 pairs) and "KBDID B" (on the second six). The other four pairs of pins correspond to bits 3-0 of the second ID byte; these would need to be set with jumpers.

http://www.seasip.info/VintagePC/ibm_6110344.html

Scan Codes

This lists scan codes supported by Windows.

https://web.archive.org/web/20090206085854/http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/translate.pdf

'Keyboard Scan Code Specification Appendix A' of Microsoft gives really details for Scan Code Set 1 and 2.

https://babbage.cs.qc.cuny.edu/courses/cs345/Manuals/ms_scancode.pdf

https://web.archive.org/web/20201112031338/download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc

0x00 and 0xFF should not be used as scan code. 0x00 indicates error in scan code set 2 and 3 while 0xFF does in scan code set 1. (P.199/4-48) The system defaults to scan set 2, but can be switched to set 1 or set 3. (p.200)

http://bitsavers.org/pdf/ibm/pc/at/6183355_PC_AT_Technical_Reference_Mar86.pdf

Scan Code Set 1

IBM XT 83-key

https://www.seasip.info/VintagePC/ibm_1501105.html

Scan Code Set 2

The break code consists of 2 bytes, the first of which is the break code prefix, hex F0; the second byte is the same as the make scan code for that key.

Exceptional Key Handling

https://github.com/tmk/tmk_keyboard/blob/c6a6049bc85609b05a6502dbbed524d669b2b7a5/converter/ibmpc_usb/ibmpc_usb.c#L605-L668

System Request and Print Screen

The 'System Request' key(0x84) was introduced on IBM PC/AT 84-key and integrated into 'Print Screen' key later on Enhanced 101-key. Alt + 'Print Screen' generates scan code 0x84.

https://en.wikipedia.org/wiki/System_request

IBM AT 84-key

As the page below refers, this is completely subset of Code Set 3 in terms of key positions including hidden keys. It is correspond to Code Set 2 in terms of key ledgends. It may be straight to handle this as Code Set 3.

https://www.seasip.info/VintagePC/ibm_6450225.html

IBM 102-key

https://www.seasip.info/VintagePC/ibm_1391406.html

Universal 128-key

This is colleciton of common scan codes form variaous available resources.

Scan Code Set 2:
        ,-----------------------------------------------.
        |F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24|
,---.   |-----------------------------------------------|     ,-----------.     ,-----------.
|Esc|   |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|     |PrS|ScL|Pau|     |VDn|VUp|Mut|
`---'   `-----------------------------------------------'     `-----------'     `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
|  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|JPY|Bsp| |Ins|Hom|PgU| |NmL|  /|  *|  -|
|-----------------------------------------------------------| |-----------| |---------------|
|Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|  \  | |Del|End|PgD| |  7|  8|  9|  +|
|-----------------------------------------------------------| `-----------' |---------------|
|CapsL |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '| ^a|Entr|               |  4|  5|  6|KP,|
|-----------------------------------------------------------|     ,---.     |---------------|
|Shft|  <|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /| RO|Shift |     |Up |     |  1|  2|  3|Ent|
|-----------------------------------------------------------| ,-----------. |---------------|
|Ctl|Gui|Alt|MHEN|     Space      |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| |  #|  0|  .|KP=|
`-----------------------------------------------------------' `-----------' `---------------'

        ,-----------------------------------------------.
        | 08| 10| 18| 20| 28| 30| 38| 40| 48| 50| 57| 5F|
,---.   |-----------------------------------------------|     ,-----------.     ,-----------.
| 76|   | 05| 06| 04| 0C| 03| 0B| 83| 0A| 01| 09| 78| 07|     |+7C| 7E|+77|     |*21|*32|*23|
`---'   `-----------------------------------------------'     `-----------'     `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
| 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 6A| 66| |*70|*6C|*7D| | 77|*4A| 7C| 7B|
|-----------------------------------------------------------| |-----------| |---------------|
| 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B|  5D | |*71|*69|*7A| | 6C| 75| 7D| 79|
|-----------------------------------------------------------| `-----------' |---------------|
| 58   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| ^a| 5A |               | 6B| 73| 74| 6D|
|-----------------------------------------------------------|     ,---.     |---------------|
| 12 | 61| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A| 51|  59  |     |*75|     | 69| 72| 7A|*5A|
|-----------------------------------------------------------| ,-----------. |---------------|
| 14|*1F| 11| 67 |     29         | 64 | 13 |*11|*27|*2F|*14| |*6B|*72|*74| | 68| 70| 71| 63|
`-----------------------------------------------------------' `-----------' `---------------'
*: E0-prefixed codes
+: Special codes sequence
^a: ISO hash key uses identical scancode 5D to US backslash.
51, 63, 68, 6A, 6D: Hidden keys in IBM model M [6]

SKIDATA2-DE(KCX50BK02-DE) by TIPRO

https://gist.github.com/tmk/22b381c13f9a87b2e314d4caf578ac8d

Cherry G80-2551 in Code Set 2

The keyobard stars up with Code Set 2 and can be switched to Code Set 3.

https://geekhack.org/index.php?topic=103648.msg2894275#msg2894275

https://gist.github.com/tmk/22cb8680ca8ef854630ecd1953268c5b

Siemens S26381-K257-L120

https://www.picclickimg.com/00/s/OTAwWDE2MDA=/z/rOAAAOSwaMRgVIvQ/$/PC-Tastatur-SIEMENS-KBPC-EM-D-S26381-K257-L120-_57.jpg

Scan codes for the second row from the top:

Key: ESC markier/CH.CODE Blind druck 1/MODE druck 2/DRUCK Blind Zeichen WORT Zeile Blind Zeichen Daten/WORT Zeile Blind >/HELP </START ^/END DRUCK K1/ROLL K2/PAUSE skip/K3 lΓΆ.Bild/rs.Anz./NumL Blind
Scan Code: r76 r08 r0F r18 r10 r67 rE0+r70 r84 r51 r68 r6F r50 r64 r6A r63 r5C r28 rE0+r12+rE0+r7C r7E rE1+r14+r77 r20 r77 r17
TMK unimap: Esc F13 RALT F15 F14 MHEN Insert PrintScreen RO NUHS MUTE F22 HENK JYEN KP= APP F17 PrintScreen ScrollLock Pause F16 Num Lock RCTL

Scan codes for bottom row:

Keys: CTRL Blind ALT Spacebar Compose/AltGr </CTRL Send/Menu
Scan code: r14 r27 r11 r29 rE0+r11 rE0+r14 r48
TMK unimap: LCTL END LALT Alt SPACE RALT RCTL F21

https://geekhack.org/index.php?topic=103648.msg3033910#msg3033910

Keyboard ID: AB83

https://geekhack.org/index.php?topic=103648.msg3033527#msg3033527

Scan Code Set 3

The break code consists of 2 bytes, the first of which is the break-code prefix, hex F0; the second byte is the same as the make scan code for that key.

http://www.mcamafia.de/pdf/ibm_hitrc11.pdf

IBM Terminal 122-key

https://www.seasip.info/VintagePC/ibm_6110344.html https://www.seasip.info/VintagePC/ibm_1390876.html

IBM Terminal 101-key/102-key

,---.   ,---------------. ,---------------. ,---------------. ,-----------.
| 08|   | 07| 0F| 17| 1F| | 27| 2F| 37| 3F| | 47| 4F| 56| 5E| | 57| 5F| 62|
`---'   `---------------' `---------------' `---------------' `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
| 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 5D| 66| | 67| 6E| 6F| | 76| 77| 7E| 84|
|-----------------------------------------------------------| |-----------| |---------------|
| 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B|  5C | | 64| 65| 6D| | 6C| 75| 7D| 7C|
|-----------------------------------------------------------| `-----------' |---------------|
| 14   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 53| 5A |               | 6B| 73| 74| 7B|
|-----------------------------------------------------------|     ,---.     |---------------|
| 12 | 13| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A| 51|  59  |     | 63|     | 69| 72| 7A| 79|
|-----------------------------------------------------------| ,-----------. |---------------|
| 11  |   |19  |        29                   |39  |   | 58  | | 61| 60| 6A| | 68| 70| 71| 78|
`-----'   `---------------------------------------'   `-----' `-----------' `---------------'

IBM 1390876 102-key PC Code Set 3: http://www.seasip.info/VintagePC/ibm_1391406.html

IBM 1394204 101-key Terminal Code Set 3: https://github.com/tmk/tmk_keyboard/issues/687#issuecomment-852604123

G80-3600 and SKIDATA2-DE in Code Set 3

Japanese specific keys and extra keys of modern PC keyboard

Key Code
焑倉換(Japanese Muhenkan) 85
倉換(Japanese Henkan) 86
γ²γ‚‰γŒγͺ 87
LGUI 8B
RGUI 8C
Application 8D

G80-2551 in Code Set 3

The keyboard can be switch to Scan Code Set 3 with 'Select Alternate Scan Codes'command (F0 03).

              ,-----------------------------------------------.
              | 08| 10| 18| 20| 28| 30| 38| 40| 48| 50| 57| 5F|
              |-----------------------------------------------|
              | 07| 0F| 17| 1F| 27| 2F| 37| 3F| 47| 4F| 56| 5E|
              `-----------------------------------------------'
,-------. ,-----------------------------------------------------------. ,-----------. ,---------------.
| 05| 06| | 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55|     66| | 67| 6E| 6F| | 76| 77| 7E| 84|
|-------| |-----------------------------------------------------------| |-----------| |---------------|
| 04| 0C| | 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B|     | | 64| 65| 6D| | 6C| 75| 7D| 7C|
|-------| |------------------------------------------------------`    | |-----------| |---------------|
| 03| 0B| | 14   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 53| 5A | |-26| 63|-25| | 6B| 73| 74| 7B|
|-------| |-----------------------------------------------------------| |-----------| |---------------|
| 83| 0A| | 12 | 13| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A|      59  | | 61| 62| 6A| | 69| 72| 7A| 79|
|-------| |-----------------------------------------------------------| |-----------| |-----------|   |
| 01| 09| | 11  |   |19  |        29                   |39  |   | 58  | |-16| 60|-1E| |     70| 71|   |
`-------' `-----'   `---------------------------------------'   `-----' `-----------' `---------------'
-: 0x80 prefixed(G80-2551 specific)

Its scan codes are identical to IBM 122-key terminal keyboard except for four extra key around cursors.

https://geekhack.org/index.php?topic=103648.msg2894921#msg2894921

https://gist.github.com/tmk/22cb8680ca8ef854630ecd1953268c5b

IBM 5576 Scan Codes Set

The 5576 keyboard series supports special code sets.

The 5576 keyboads starts up with Code Set 2 which doesn't enable Japanese specific keys and emulates US layout. Code Set 2 is not useuful in fact. TMK IBMPC converter uses Code Set 3 for 5576-001 and Code Set 82h for 5576-002 and 5576-003. Resouces says 5576-001 doesn't support Code Set 1, 3 and 81h, though, 5576-001 can work with Code Set 3 actually.

5576-A01 is completely compatible to standard Japanese PS/2 keyboard.

Code Set Description
1 without Japanese specific key support
2 without Japanese specific key support
3 All keys can be used
81h Code Set 1 with Japanese specific key support
82h Code Set 2 with Japanese specific key support
8Ah IBM 5550 compatible

https://diarywind.com/blog/e/ibm-5576002-keyboard-info.html

http://radioc.web.fc2.com/column/ps55/ps55kbd_scancode.htm

https://www.win.tue.nl/~aeb/linux/kbd/scancodes-8.html#ss8.3

IBM 5576 Keyboard Layout

5576-001: http://zigsow.jp/img.php?a=a&filename=mi_100977_1359272740_1521804289.jpg

5576-002: https://upload.wikimedia.org/wikipedia/commons/8/83/IBM_5576_002_Keyboard.jpg

5576-003: https://pbs.twimg.com/media/EOSuNygUUAISROB?format=jpg&name=4096x4096

5576-A01: http://blog-imgs-75.fc2.com/k/c/g/kcg0319/securedownload_20150302100522d30.jpg

IBM 5576 Code Set 82h

5576-002/003

This should be confirmed.

IBM 5576-002 106-key Code Set 82h:
,---.   ,-----------------------------------------------.     ,-----------.
| 76|   | 05| 06| 04| 0C| 03| 0B| 83| 0A| 01| 09| 78| 07|     |+7C| 7E|+77|
`---'   `-----------------------------------------------'     `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
| 62| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 5D| 66| |*70|*6C|*7D| | 7C|*4A|*41| 7B|
|-----------------------------------------------------------| |-----------| |---------------|
| 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 0E| 54|     | |*71|*69|*7A| | 6C| 75| 7D|   |
|------------------------------------------------------`    | `-----------' |-----------| 79|
| 58   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 5B| 5A |               | 6B| 73| 74|   |
|-----------------------------------------------------------|     ,---.     |---------------|
| 12     | 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A| 51|  59  |     |*75|     | 69| 72| 7A|   |
|-----------------------------------------------------------| ,-----------. |-----------|*5A|
| 14  |   |  13 |  67  |  29   |  64  | *11 |  11 |   | *14 | |*6B|*72|*74| |     70| 71|   |
`-----'   `---------------------------------------'   `-----' `-----------' `---------------'
*: E0 prefixed  
+: Special scan code sequence
Speculation from 5576-001 CS82h and Quckey! translation table.

Quckey! PS/2 Converter uses Code Set 82h and convert 5576-002 to standard JIS 106-key keyboard.

uckey! Translation:
KP*    7C -> 77     NumLock
KP'   *41 -> 7C     KP*
半/ε…¨  62 -> 0E     `~
       0E -> 54     [
       54 -> 5B     ]
       5B -> 5D     \
       5C -> 6A     JYEN
       5D -> 6A     JYEN
       11 -> *11    RAlt
       13 -> 11     LAlt
      *11 -> 13     KANA

https://www.soramimi.jp/quckey/index.html

5576-001

Code Set 82h is not useful for 5576-001, which is a terminal keyboard and fits better with Code Set 3.

5576-001 124-key Code Set 82h:
             ,---------------.  ,---------------.  ,---------------.                                                   
             |^7C| 7E| 1F| 27|  | 2F| 5E| 08| 10|  | 50| 18| 17| 37|                                                   
             |----------------  |----------------  |---------------|
             | 05| 06| 04| 0C|  | 03| 0B| 83| 0A|  | 01| 09| 78| 07|
             `---------------'  `---------------'  `---------------'
,-------. ,-----------------------------------------------------------. ,-----------. ,---------------.                
| 5F| 48| | 76| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 5D| 66| |*7D|*69|*7A| | 7C|*4A|*41| 7B|                
|-------| |-----------------------------------------------------------| |-----------| |---------------|                
| 38|^77| | 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 0E| 54|     | |*70|*71|*40| | 6C| 75| 7D| 79|                
|-------| |------------------------------------------------------`    | `-----------' |---------------|                
| 30| 62| | 13   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 5B| 5A |     |*75|     | 6B| 73| 74|   |                
|-------| |-----------------------------------------------------------| ,-----------. |-----------|   |                
| 20| 28| | 12     | 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A| 51|  59  | |*6B|*6C|*74| | 69| 72| 7A|*5A|                
|-------| |-----------------------------------------------------------| `-----------' |-----------|   |                
| 60| 14| | 11  |  |  58  |  67   |  29   |  64   |*11 |        |*14  |     |*72|     |     70| 71|   |                
`-------' `-----'  `-----------------------------------'        `-----'     `---'     `---------------'                
*: E0 prefixed                                                                                                         
^7C: rE0 r12 rE0 r7C rE0 rF0 r7C rE0 rF0 r12
^77: rE1 r14 r77 rE1 rF0 r14 rF0 r77

https://github.com/tmk/tmk_keyboard/issues/685#issuecomment-850855323

IBM 5576 Code Set 3

5576-001

IBM 5576-001 124-key Code Set 3:
             ,---------------.  ,---------------.  ,---------------.
             | 08| 10| 18| 20|  | 28| 30| 38| 40|  | 48| 50| 57| 5F|
             |----------------  |----------------  |---------------|
             | 07| 0F| 17| 1F|  | 27| 2F| 37| 3F|  | 47| 4F| 56| 5E|
             `---------------'  `---------------'  `---------------'
,-------. ,-----------------------------------------------------------. ,-----------. ,---------------.
| 05| 06| | 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55|+13| 66| | 67| 6E| 6F| |+7E| 77|+76| 84|
|-------| |-----------------------------------------------------------| |-----------| |---------------|
| 04| 0C| | 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B|     | | 64| 65| 6D| | 6C| 75| 7D| 7C|
|-------| |------------------------------------------------------`    | `-----------' |---------------|
| 03| 0B| | 14   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 53| 5A |     | 63|     | 6B| 73| 74|   |
|-------| |-----------------------------------------------------------| ,-----------. |-----------|   |
| 83| 0A| | 12     | 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A|+5C|  59  | | 61| 62| 6A| | 69| 72| 7A| 79|
|-------| |-----------------------------------------------------------| `-----------' |-----------|   |
| 01| 09| | 11  |  | 19  |  85   |  29   |  86   | 39  |        | 58  |     | 60|     |     70| 71|   |   
`-------' `-----'  `-----------------------------------'        `-----'     `---'     `---------------'
+: different from IBM 122-key Terminal [5D->13, 51->5C, 76->7E, 7E->76]

https://github.com/tmk/tmk_keyboard/issues/685#issuecomment-850761559

Translation to Set 1 of i8042

|SC|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|

https://www.win.tue.nl/~aeb/linux/kbd/scancodes-10.html#ss10.3

0x7F(SysRq on Zenith Z-150 AT) and 0x84(SysRq, Alt+PrtSc) of CS2 are translated into 0x54(Alt+PrtSc*) of CS1.

https://geekhack.org/index.php?topic=103648.msg2897404#msg2897404

0x02(not used) and 0x83(F7) of CS2 are translated into 0x41(F7) of CS1.

Translation to HID usages of Microsoft

Scan code set 1 and 2 are also listed in Scan Code Translation Table of Microsoft.

Interface

Connector

AT - DIN 5P 180Β°, SDL

p.188 of http://bitsavers.org/pdf/ibm/pc/at/6183355_PC_AT_Technical_Reference_Mar86.pdf

PS/2 - Mini-DIN 6P

(Mini-DIN 6P Socket) http://www.mcamafia.de/pdf/ibm_hitrc07.pdf

Terminal - DIN 5P 240Β°, RJ45 8P5C

Host side schematics

p.111 of http://bitsavers.org/pdf/ibm/pc/at/6183355_PC_AT_Technical_Reference_Mar86.pdf

p.132 of http://bitsavers.org/pdf/ibm/pc/at/6183355_PC_AT_Technical_Reference_Mar86.pdf

p.95 of http://bitsavers.org/pdf/ibm/pc/at/1502494_PC_AT_Technical_Reference_Mar84.pdf

i8042

PC/AT 8042 seems to support XT keyboard when bit 5 of CMD(@$20) is on.(0115:) The bit can be written by host with 60 'Write Command Byte' command. Meanwhile, PS/2 8042 doesn't support XT keyboard, it doesn't check bit 5 of CMD byte.

http://halicery.com/8042/8042_1503033.TXT

Keyboard side schematics

101-key

p.233 of http://bitsavers.org/pdf/ibm/pc/at/6183355_PC_AT_Technical_Reference_Mar86.pdf

84-key

http://www.kbdbabel.org/schematic/kbdbabel_doc_ibmat_kbd.pdf

AT/XT Auto-Switch

https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-Keyboard-Converter#atxt-auto-switching

Weirdness

Zenith Z-150 AT

https://deskthority.net/wiki/Zenith_Z-150

This keyboard's compatibility to AT protocol seems to be very bad. It works somewhat with some converter or PS/2 port on PC while not at all with others.

See wafeform above. It is obviously violation of IBM AT protocol.

TMK IBMPC Converter

The converter can read scan code from the keyboard without stop bit check but it fails to send commands when lock indicator is updated.

Lock Indicators

It seems to accept 'ED' command from some computer, LEDs can be controlled normally from host. But TMK converter and most of PS/2 ports fails to send 'Set Indicator' commands.

The lock keys of a separate keyboard do indeed turn on the corresponding indicator LED of the Zenith when connected to the HP.

https://geekhack.org/index.php?topic=103648.msg2896728#msg2896728

Over native ps/2 the lock lights will similarly fail to register with rapid presses and causes a reset. The only difference I see compared to with the converter is that the board does a "softer reset" such that the beeper on/off state is not changed.

https://geekhack.org/index.php?topic=103648.msg3050259#msg3050259

Monoprice PS/2 Converter

http://www.newegg.com/Product/Product.aspx?Item=9SIA8SV3807929

I have a beige-label, which is the AT model. It works fine with the linked PS/2 -> USB converter, after a DIN -> PS/2 converter as well of course. I can try to find the DIN -> PS/2 converter online if that matters, it looks very generic. The only issue I've run into is that the F7 key only works over PS/2, the USB converter seems to prevent that specific key from being sent (the internal buzzer still beeps when it is pressed, the PC just never recieves the code). I have tried a BlueCube and it doesn't work at all, strangely enough.

https://deskthority.net/viewtopic.php?p=293309#p293309

Another witness: Monprice converter works with the Z-150 but it doesn't control lock indicators and doesn't handle F7 key but others.

https://geekhack.org/index.php?topic=103648.msg2900928#msg2900928

Yet another: F7(0x83) issue https://geekhack.org/index.php?topic=79453.0

Belkin one

This works but has F7(0x83) issue as well.

https://geekhack.org/index.php?topic=79453.msg2048467#msg2048467

Soarer's doesn't work

Due to 'stop bit error' . https://geekhack.org/index.php?topic=103648.msg2898418#msg2898418

BlueCube doesn't work

https://deskthority.net/viewtopic.php?p=293309#p293309

TMK PS/2 INT doesn't work

https://deskthority.net/viewtopic.php?p=297627#p297627

Doesn't work even with PS/2 port on PC

I tried using a very generic at to ps2 adapter then a blue cube and didn't have any luck. The keyboard lights up the first time you plug it in. Edit: I was messing with the adapters and if I go from at to ps2 into my ps2 port the keyboard works during post. Edit 2: It only works for a few moments during post. Eventually it stops beeping.

https://deskthority.net/viewtopic.php?p=353558#p353558

Some computers work but others not

It had perfect function on my: HP 8200/8300 Compaq SR1920nx (yeah, that's an oldie, my first desktop computer) It had partial function by mashing the caps lock key many times on an old Dell XPS 630, in Linux Mint ... maybe 17 or so. The same trick didn't work in Windows 10. It didn't work at all on any other computer I tried.

https://geekhack.org/index.php?topic=103648.msg2896728#msg2896728

Break on Unicomp PS/2

Control + Pause doesn't seems to be handled correctly.

https://deskthority.net/viewtopic.php?f=2&t=25718

Resources

TrackPoint Engineering Specifications for version 3E

https://web.archive.org/web/20100613123840/http://wwwcssrv.almaden.ibm.com/trackpoint/files/ykt3eext.pdf

https://web.archive.org/web/20100526161812/http://wwwcssrv.almaden.ibm.com/trackpoint/download.html

MF2 Keyboard

The expression MF2 keyboard stands for multi-functional keyboard version 2. This type of keyboard was first developed and defined by IBM for use with all types of PC (XT, AT, PS/2). In the meantime it has become an industry standard and today nearly all PCs have an MF2 compatible keyboard.

The MF2 keyboard supports 3 different sets of make and break codes. Code set 1 is used for XT/PC and PS/2 –30 compatible computers. Code set 2 is used for AT and all other PS/2 models compatible computers and code set 3 is used for workstations and terminal emulations on the PC.

http://bitsavers.trailing-edge.com/components/national/_appNotes/AN-0734.pdf

IBM 84-key Model F (AT) keyboard ROM