Skip to content

IBM PC Keyboard Converter

hasu@tmk edited this page Oct 27, 2023 · 64 revisions

TMK IBM PC Keyboard Converter

TMK Converter

You can buy prebuilt conveter here and support this project.

Resources

Keyboard Discrimination

This section explains how the converter determines proper protocol and scan code set for keyboard. The converter need to do that before starting to receive and translate scan codes from keyboard.

Keyboard ID

After startup the converter sends 0xF2 command to get keyboard ID and sees how the keyboard responds to the command.

Response from keyboard:

  • XT keyboard doesn’t support any command and returns no response.

  • AT keyboard should respond with 0xFA to the command but returns no keyboard ID.

  • PS/2 keyboard should respond with 0xFA to the command, followd by keyboard ID, such as 0xAB86.

  • Terminal keyboard should respond with 0xFA to the command, followed by keyboard ID, such as 0xBFBF.

  • PS/2 mouse should respond with 0xFA to the command, followd by single-byte ID 0x00.

Now we can dscriminate the keyboard and determine suitable protocol and scan code set as described below.

Protocol

  • Signals from XT keyboard are recognized by XT protocol.

  • Signals from AT, PS/2 and Terminal keyboard are recognized by AT protocol.

  • Signals from PS/2 mouse are also recognized by AT protocol.

Scan code Set

  • Scan codes from XT keyboard are handled as CodeSet1.

  • Scan codes from AT and PS/2 keyboard are handled as CodeSet2.

  • Scan codes from Terminal keyhboard are handled as CodeSet3.

Default Mapping

XT - Scan Code Set 1

XT 83-key

,-------.  ,--------------------------------------------------------------------------.
| F1| F2|  |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  BS  |NumLck |ScrLck |
|-------|  |--------------------------------------------------------------------------|
| F3| F4|  | Tab |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ] |   |  7|  8|  9|  -|
|-------|  |------------------------------------------------------|Ent|---------------|
| F5| F6|  | Ctrl |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  `|   |  4|  5|  6|   |
|-------|  |----------------------------------------------------------------------|   |
| F7| F8|  |Shif|  \|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift|  *|  1|  2|  3|  +|
|-------|  |----------------------------------------------------------------------|   |
| F9|F10|  |  Alt  |               Space                  |CapsLck|   0   |   .   |   |
`-------'  `--------------------------------------------------------------------------'
,-------.  ,--------------------------------------------------------------------------.
| 3B| 3C|  | 01| 02| 03| 04| 05| 06| 07| 08| 09| 0A| 0B| 0C| 0D|  0E  |  45   |  46   |
|-------|  |--------------------------------------------------------------------------|
| 3D| 3E|  | 0F  | 10| 11| 12| 13| 14| 15| 16| 17| 18| 19| 1A| 1B |   | 47| 48| 49| 4A|
|-------|  |------------------------------------------------------| 1C|---------------|
| 3F| 40|  | 1D   | 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 28| 29|   | 4B| 4C| 4D|   |
|-------|  |----------------------------------------------------------------------|   |
| 41| 42|  | 2A | 2B| 2C| 2D| 2E| 2F| 30| 31| 32| 33| 34| 35|  36 | 37| 4F| 50| 51| 4E|
|-------|  |----------------------------------------------------------------------|   |
| 43| 44|  |  38   |              39                      |  3A   |  52   |  53   |   |
`-------'  `--------------------------------------------------------------------------'

Full-key

        ,-----------------------------------------------.
        |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|  ;|  '|  #|Entr|               |  4|  5|  6|KP,|
|-----------------------------------------------------------|     ,---.     |---------------|
|Shft| ^a|  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=|
`-----------------------------------------------------------' `-----------' `---------------'
        ,-----------------------------------------------.
        | 64| 65| 66| 67| 68| 69| 6A| 6B| 6C| 6D| 6E| 76|
,---.   |-----------------------------------------------|     ,-----------.     ,-----------.
| 01|   | 3B| 3C| 3D| 3E| 3F| 40| 41| 42| 43| 44| 57| 58|     |*37| 46|*46|     |*2E|*30|*20|
`---'   `-----------------------------------------------'     `-----------'     `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
| 29| 02| 03| 04| 05| 06| 07| 08| 09| 0A| 0B| 0C| 0D| 7D| 0E| |*52|*47|*49| | 45|*35| 37| 4A|
|-----------------------------------------------------------| |-----------| |---------------|
| 0F  | 10| 11| 12| 13| 14| 15| 16| 17| 18| 19| 1A| 1B|  2B | |*53|*4F|*51| | 47| 48| 49| 4E|
|-----------------------------------------------------------| `-----------' |---------------|
| 3A   | 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 28| 56| 1C |               | 4B| 4C| 4D| 7E|
|-----------------------------------------------------------|     ,---.     |---------------|
| 2A | ^a| 2C| 2D| 2E| 2F| 30| 31| 32| 33| 34| 35| 73|  36  |     |*48|     | 4F| 50| 51|*1C|
|-----------------------------------------------------------| ,-----------. |---------------|
| 1D|*5B| 38| 7B |      39        | 79 | 70 |*38|*5C|*5D|*1D| |*4B|*50|*4D| |     52| 53| 59|
`-----------------------------------------------------------' `-----------' `---------------'
*: E0-prefixed codes. See cs1_e0code() for remapping to unimap array.
PrintScreen: E0 37 or 54(with Alt) -> 54
Pause: E1 1D 45 or E0 46(with Ctrl) -> 55
^a: ISO backslash and US backslash use identical code 2B. [3], [a]
Unsupported codes or error -> 00. UNIMAP_NUBS is unused.

AT - Scan Code Set 2

AT 84-key

,-------. ,-----------------------------------------------------------. ,---------------.
| F1| F2| |  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  \| BS| |Esc|NmL|ScL|PrS|
|-------| |-----------------------------------------------------------| |---------------|
| F3| F4| |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|  App| |  7|  8|  9|  *|
|-------| |-----------------------------------------------------------| |-----------|---|
| F5| F6| |LCtrl |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Lef| Ret| |  4|  5|  6|  -|
|-------| |-----------------------------------------------------------| |---------------|
| F7| F8| |Shif|KAN|  Z|  X|  C|  V|  B|  N|  M|  ,|  ,|  /| RO| Shift| |  1|  2|  3|  +|
|-------| |-----------------------------------------------------------| |-----------|---|
| F9|F10| | Alt|    | Gui|          Space              | Ins|    |Caps| |  #|  0|  .|F11|
`-------' `----'    `---------------------------------------'    `----' `---------------'
,-------. ,-----------------------------------------------------------. ,---------------.
| 05| 06| | 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 5D| 66| | 76| 77| 7E| 84|
|-------| |-----------------------------------------------------------| |---------------|
| 04| 0C| | 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B| -5C | | 6C| 75| 7D| 7C|
|-------| |-----------------------------------------------------------| |---------------|
| 03| 0B| | 14   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52|-53| 5A | | 6B| 73| 74| 7B|
|-------| |-----------------------------------------------------------| |---------------|
|*83| 0A| | 12 |-13| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A|-51|  59  | | 69| 72| 7A| 79|
|-------| |-----------------------------------------------------------| |---------------|
| 01| 09| | 11  |   | -19|        29                   | -39|   | 58  | |-68| 70| 71|-78|
`-------' `-----'   `---------------------------------------'   `-----' `---------------'
-: Hidden keys

Full-key

        ,-----------------------------------------------.
        |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. See cs2_e0code() for remapping to unimap array.
+: Special codes sequence
^a: ISO hash key and US backslash use identical code 5D.
51, 63, 68, 6A, 6D: Hidden keys in IBM model M [6]
AX keyboard
Details
,---.   ,---------------. ,---------------. ,---------------. ,-----------.
|App|   |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| 
`---'   `---------------' `---------------' `---------------' `-----------' 
,-----------------------------------------------------------. ,-----------. ,---------------.
|Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  \|Bsp| |Ins|Hom|PgU| |NmL|  /|  *|  -|
|-----------------------------------------------------------| |-----------| |---------------|                                                     
|Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|     | |Del|End|PgD| |  7|  8|  9|  +|                                                     
|------------------------------------------------------`    | `-----------' |-----------|   |                                                     
|Ctrl  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  `|Retn|               |  4|  5|  6|   |                                                     
|-----------------------------------------------------------|     ,---.     |---------------|                                                     
|Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|  <|Shift |     |Up |     |  1|  2|  3|Ent|
|-----------------------------------------------------------| ,-----------. |-----------|   |
|Caps |   | Alt | LGui |  SPC  |   RGui    | Alt  |   |Ctrl | |Lef|Dow|Rig| |  0    |  .|   |
`-----'   `---------------------------------------'   `-----' `-----------' `---------------'
,---.   ,---------------. ,---------------. ,---------------. ,-----------. 
|^27|   | 05| 06| 04| 0C| | 03| 0B| 83| 0A| | 01| 09| 78| 07| |+7C| 7E|+77|
`---'   `---------------' `---------------' `---------------' `-----------'                                                                       
,-----------------------------------------------------------. ,-----------. ,---------------.                                                     
|^76| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55|^5D| 66| |*70|*6C|*7D| | 77|*4A| 7C| 7B|                                                     
|-----------------------------------------------------------| |-----------| |---------------|                                                     
| 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B|     | |*71|*69|*7A| | 6C| 75| 7D| 79|                                                     
|------------------------------------------------------`    | `-----------' |-----------|   |                                                     
|^14   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52|^0E| 5A |               | 6B| 73| 74|   |                                                     
|-----------------------------------------------------------|     ,---.     |---------------|                                                     
| 12     | 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A|^61|  59  |     |*75|     | 69| 72| 7A|*5A|                                                     
|-----------------------------------------------------------| ,-----------. |-----------|   |                                                     
|^58  |   | 11  |  ^17 |   29  |   ^1F     | *11  |   | *14 | |*6B|*72|*74| | 68| 70| 71|   |                                                     
`-----'   `---------------------------------------'   `-----' `-----------' `---------------'                                                     
^: AX specific
*: E0-prefixed
Tandberg TDV 5020
Details
,---.   ,---------------.  ,---------------.  ,---------------. ,-----------. ,---------------.
|Esc|   |F1 |F2 |F3 |F4 |  |F5 |F6 |F7 |F8 |  |F9 |F10|F11|F12| |PrS|ScL|Pau| |F13|F14|F15|F16|
`---'   `---------------'  `---------------'  `---------------' |-----------| |---------------|
                                                                |F17|F18|F19| |F20|F21|F22|F23|
,-------------------------------------------------------------. |-----------| |---------------|
|    `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|   |Bsp| |Ins|Hom|PgU| |NmL|  /|  *|  -|
|-------------------------------------------------------------| |-----------| |---------------|
|F24|Tab|  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ] |    | |Del|End|PgD| |  7|  8|  9|  +|
|--------------------------------------------------------|    | |-----------| |-----------|   |
|Gui|Caps|  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  \|Entr| |VDn|VUp|Mut| |  4|  5|  6|   |
|-------------------------------------------------------------| |-----------| |---------------|
|Shift |  <|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /| Shift| RO| |Gui|Up |App| |  1|  2|  3|Ent|
|-------------------------------------------------------------| |-----------| |-----------|   |
|Ctl|    |Alt| |            Space              | |Alt|    |Ctl| |Lef|Dow|Rig| |      0|  .|   |
`---'    `---' `-------------------------------' `---'    `---' `-----------' `---------------'

,---.   ,---------------.  ,---------------.  ,---------------. ,-----------. ,---------------.
| 76|   | 05| 06| 04| 0C|  | 03| 0B| 83| 0A|  | 01| 09| 78| 07| |+7C| 7E|+77| |^2B|^34|^33|^42|
`---'   `---------------'  `---------------'  `---------------' |-----------| |---------------|
                                                                |^2C|^3C|^43| |^4B|^2A|^32|^3A|
,-------------------------------------------------------------. |-----------| |---------------|
|   0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55|^61| 66| |*70|*6C|*7D| | 77|*4A| 7C| 7B|
|-------------------------------------------------------------| |-----------| |---------------|
|^1D| 0D| 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B |    | |*71|*69|*7A| | 6C| 75| 7D| 79|
|--------------------------------------------------------|    | |-----------| |-----------|   |
|^24| 58 | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 5D| 5A | |^44|^4D|^1C| | 6B| 73| 74|   |
|-------------------------------------------------------------| |-----------| |---------------|
| 12   | 61| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A|  59  |^2D| |^1B|*75|^23| | 69| 72| 7A|*5A|
|-------------------------------------------------------------| |-----------| |-----------|   |
| 14|    | 11| |             29                | |*11|    |*14| |*6B|*72|*74| |     70| 71|   |
`---'    `---' `-------------------------------' `---'    `---' `-----------' `---------------'
*: E0-prefixed codes
+7C: E0 12 E0 7C
+77: E1 14 77 E1 F0 14 F0 77
^: 80-prefixed codes

Media Keys

Keys described in Microsoft document                                                                                   

Key                     Scan Code   TMK default    HID                                                                 
-------------------------------------------------------------
Scan Next Track         E0 4D       F16            0C 00B5                                                             
Scan Previous Track     E0 15       F15            0C 00B6
Stop                    E0 3B       F14            0C 00B7
Play/ Pause             E0 34       F13            0C 00CD    
Mute                    E0 23       MUTE           0C 00E2    
Volume Up               E0 32       VOLU           0C 00E9    
Volume Down             E0 21       VOLD           0C 00EA    
Media Select            E0 50       F17            0C 0183
Mail                    E0 48       F21            0C 018A
Calculator              E0 2B       F22            0C 0192
My Computer             E0 40       F20            0C 0194    
WWW Search              E0 10       F13            0C 0221    
WWW Home                E0 3A       F19            0C 0223
WWW Back                E0 38       F18            0C 0224
WWW Forward             E0 30       F17            0C 0225
WWW Stop                E0 28       F16            0C 0226
WWW Refresh             E0 20       F15            0C 0227
WWW Favorites           E0 18       F14            0C 022A                                                             
System Power            E0 37       F24            01 81
System Sleep            E0 3F       F23            01 82
System Wake             E0 5E       F22            01 83
        

Silitek SK-7100P

Details
Key                     Scan code   TMK default
-------------------------------------------
Close                   E0 43       F20*
CD                      E0 42       F21*
Video                   E0 44       F22*
www                     E0 3A       F19
U/P                     E0 1C       F18*
RR                      E0 15       F15
Pause                   E0 24       F17*
Play                    E0 34       F13
Stop                    E0 3B       F14
FF                      E0 4D       F16
Vol-                    E0 21       VOLD
Vol+                    E0 32       VOLU
Mute                    E0 23       MUTE
Display                 E0 4B       F24*

Terminal - Scan Code Set 3

122-key

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

              ,-----------------------------------------------.
              | 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| 5D| 66| | 67| 6E| 6F| | 76| 77| 7E| 84|
|-------| |-----------------------------------------------------------| |-----------| |---------------|
| 04| 0C| | 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B|  5C | | 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| 51|  59  | | 61| 62| 6A| | 69| 72| 7A| 79|
|-------| |-----------------------------------------------------------| |-----------| |---------------|
| 01| 09| | 11  |   | 19  | ^85 |   29    | ^86 |  87 | 39  |   | 58  | |-16| 60|-1E| | 68| 70| 71| 78|
`-------' `-----'   `---------------------------------------'   `-----' `-----------' `---------------'
-: G80-2551 specific 80-prefixed codes remapped: 26->5D, 25->53, 16->51, 1E->00
^: 5576-001 Japanese keys
51, 5C, 5D, 68, 78: Hidden keys in IBM 122-key terminal keyboard [7]
- https://www.seasip.info/VintagePC/ibm_6110344.html - https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#g80-2551-in-code-set-3

Full-key

Details
        ,-----------------------------------------------.
        |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|  ;|  '|  #|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|   | 07| 0F| 17| 1F| 27| 2F| 37| 3F| 47| 4F| 56| 5E|     | 83| 7E| 6C|     | 03| 04| 05|
`---'   `-----------------------------------------------'     `-----------'     `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
| 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 5D| 66| | 65| 62| 6E| | 77| 67| 84| 7B|
|-----------------------------------------------------------| |-----------| |---------------|
| 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B|  5C | | 6D| 64| 6F| | 6C| 75| 7D| 7C|
|-----------------------------------------------------------| `-----------' |---------------|
| 14   | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 53| 5A |               | 6B| 73| 74| 68|
|-----------------------------------------------------------|     ,---.     |---------------|
| 12 | 13| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A| 51|  59  |     | 63|     | 69| 72| 7A| 79|
|-----------------------------------------------------------| ,-----------. |---------------|
| 11|*8B| 19|*85 |      29        |*86 |*87 | 39|*8C|*8D| 58| | 61| 60| 6A| |     70| 71| 78|
`-----------------------------------------------------------' `-----------' `---------------'
*: Special codes remmaped
IBM 5576-001
Details
             ,---------------.  ,---------------.  ,---------------.
             |F13|F14|F15|F16|  |F17|F18|F19|F20|  |F21|F22|F23|F24|
             |----------------  |----------------  |---------------|
             | F1| F2| F3| F4|  | F5| F6| F7| F8|  | F9|F10|F11|F12|
             `---------------'  `---------------'  `---------------'
,-------. ,-----------------------------------------------------------. ,-----------. ,---------------.
|Mut|HEN| |  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|JPY| BS| |  /|PgU|PgD| |Esc|NmL|ScL|  *|
|-------| |-----------------------------------------------------------| |-----------| |---------------|
|VUp|Pau| |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|     | |End|Ins|Del| |  7|  8|  9|  +|
|-------| |------------------------------------------------------`    | `-----------' |-----------|---|
|VDn|MHE| |CapsL |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  #| Ret|     |Up |     |  4|  5|  6|   |
|-------| |-----------------------------------------------------------| ,-----------. |-----------|   |
|PrS|App| |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  ,|  /| RO| Shift| |Lef|Hom|Rig| |  1|  2|  3|Ent|
|-------| |-----------------------------------------------------------| `-----------' |-----------|   |
|Gui|Gui| |LCtrl|  |LALt |  P,   |  Spc  |  P=   |RAlt |        |RCtrl|     |Dow|     |  ,|  0|  .|   |
`-------' `-----'  `-----------------------------------'        `-----'     `---'     `---------------'
             ,---------------.  ,---------------.  ,---------------.
             | 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|   |
`-------' `-----'  `-----------------------------------'        `-----'     `---'     `---------------'
+: remmaped by converter 13->5D, 5C->51, 76->7E, 7E->76
https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#ibm-5576-code-set-3
IBM Terminal 101-key/102-key and IBM RT
Details
,---.   ,---------------. ,---------------. ,---------------. ,-----------. 
|F13|   | F1| F2| F3| F4| | F5| F6| F7| F8| | F9|F10|F11|F12| |F23|F24|Hom| 
`---'   `---------------' `---------------' `---------------' `-----------' 
,-----------------------------------------------------------. ,-----------. ,---------------.
|  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|JPY|Bsp| |  /|PgU|PgD| |Esc|NmL|ScL|  *|
|-----------------------------------------------------------| |-----------| |---------------|
|Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|  \  | |End|Ins|Del| |  7|  8|  9|  +|
|-----------------------------------------------------------| `-----------' |-----------|---|
|CapsL |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  #|Entr|               |  4|  5|  6|  -|
|-----------------------------------------------------------|     ,---.     |---------------|
|Shft|  <|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /| RO|Shift |     |Up |     |  1|  2|  3|Ent|
|-----------------------------------------------------------| ,-----------. |-----------|---|
|Ctrl|    |Alt |          Space              |Alt |    |Ctrl| |Lef|Dow|Rig| |  ,|  0|  .|  =|
`----'    `---------------------------------------'    `----' `-----------' `---------------'
,---.   ,---------------. ,---------------. ,---------------. ,-----------.
| 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|
`-----'   `---------------------------------------'   `-----' `-----------' `---------------'
- https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#ibm-terminal-101-key102-key - https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#ibm-rt-keyboardcode-set-3
Televideo 990/995 DEC Style
Details
  ,-------------------.  ,-------------------.  ,---------------.   ,-----------. ,---------------.
  |F1 |F2 |F3 |F4 |F5 |  |F6 |F7 |F8 |F9 |F10|  |F11|F12|F13|F14|   |PrS|ScrLock| |Pau|VDn|VUp|Mut|
  `-------------------'  `-------------------'  `---------------'   `-----------' `---------------'
,-----------------------------------------------------------------. ,-----------. ,---------------.
|Esc|  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =| Bsp |  \| |Ins|Hom|PgU| |NmL|  /|  *|  -|
|-----------------------------------------------------------------| |-----------| |---------------|
    |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]| Entr|   |Del|End|PgD| |  7|  8|  9|  +|
 |----------------------------------------------------------    |   `-----------' |---------------|
 |Ctl|CapsL|  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|  #|    |       | Up|     |  4|  5|  6|KP,|
 |--------------------------------------------------------------|_  ,-----------. |---------------|
 | Shft |  <|  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|  Shift |RCtl| |Lef|Dow|Rig| |  1|  2|  3|Ent|
 `----------------------------------------------------------------' `-----------' |-----------|   |
      |LGui|LAlt|      Space                |RAlt|RGui|                           |      0|  .|   |
      `-----------------------------------------------'                           `---------------'
  ,-------------------.  ,-------------------.  ,---------------.   ,-----------. ,---------------.
  | 07| 0F| 17| 1F| 27|  | 2F| 37| 3F| 47| 4F|  | 56| 5E|*85|*86|   |*87|*88    | |*89|*8A|*8B|*8C|
  `-------------------'  `-------------------'  `---------------'   `-----------' `---------------'
,-----------------------------------------------------------------. ,-----------. ,---------------.
|*08| 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 66  |*57| |*6E|*67|*64| |*8D|*8E|*8F|*90|
|-----------------------------------------------------------------| |-----------| |---------------|
    | 0D  | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B|  5A |   |*65|*6D| 6F| | 6C| 75| 7D|*84|
 |----------------------------------------------------------    |   `-----------' |---------------|
 | 11|  14 | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52|*5C|    |       | 63|     | 6B| 73| 74|*7C|
 |--------------------------------------------------------------|_  ,-----------. |---------------|
 |  12  | 13| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A|    59  |*77 | | 61| 60| 6A| | 69| 72| 7A| 79|
 `----------------------------------------------------------------' `-----------' |-----------|   |
      |*91 | 19 |      29                   | 39 |*92 |                           |     70| 71|   |
      `-----------------------------------------------'                           `---------------'
*: codes traslated by converter
- https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#televideo-990995-dec-style-in-code-set-3

AT/XT Auto-Switching

AA with parity error

Some keyboards place tricky signaling to send AA(BAT OK) with prity error at startup to decide between AT and XT protocol.

         MSB               LSB
Clock:   A 9 8 7 6 5 4 3 2 1 0
Data:    1 0 1 0 1 0 1 0 1 0 0
AT:      S p D D D D D D D D s
XT:      D D D D D D D D s i i
(s:start bit, p:parity bit, S:stop bit, D:data bit, i:ignored)

TMK Converter displays it as ISR:AA90 on debug console.

  • AT host is expected to detetect its parity error and response with FE(Resend) or FF(Reset) possibly.

  • XT host is expected to ignore two preceding 0 before start bit and recognize it as AA.

TMK IBMPC converter supports this type of Auto-Switching and interprets the signaling as parity error in AT protocol.

Copam K-430

This realizes protocol auto-switching by sending AA with parity error on AT protocol first. If host/converter doesn’t detect and fails to recover the error with Resend command(FE), the keyboard switches to XT protocol immediately and no longer receive AT command.

This keyboard can work with a few PS/2 converters at least including TMK IBMPC converter.

Sending Reset command(FF) doesn’t work just after the parity error, the keyboard ingores it and switches to XT protocol.

Debug log
TMK:147575/LUFA:d6a7df

USB configured.

Loop start.
I558
620 PRT:10 ISR:AA90 rAA
624 PRT:22 ISR:AAC0 rAA A3559 wFF R R R R R R R R R R
3951 ERR:11 ISR:0000 X4452 rAA W4456 wF2 R R R R R R R R R R R5349
ID:FFFF(XT)
5349 ERR:11 ISR:AAC0 S5350 L5350 r1F r9F r20 rA0
https://geekhack.org/index.php?topic=111510.msg3086764#msg3086764

No Keyboard ID(AT84) It emulates behaviour of AT 84-key by replying to F2 command with FA but no ID.

Debug log
TMK:111e8c/LUFA:d6a7df

USB configured.

Loop start.
I776
777 ERR:02 ISR:AA90 P778 wFE rAA r00AA e00 iEA90 E781 I781 A3782 wFF rFA
3785 PRT:10 ISR:FE90 rAA W4168 wF2 rFA R5171
ID:0000(AT_AT84) S5171 wED rFA w00 rFA L5178 r84 rF0 r84 r0E rF0 r0E r0E rF0 r0E 
https://geekhack.org/index.php?topic=111510.msg3088289#msg3088289

BTC-5161

BTC-5161 requires command(Reset or Resend) to start AT mode. The keyboard sends sends the AA reapeadly at very high rate until receiving a command from host and this can makes converter buffer full.

The keyboard speaks normal AT protocol after receiving FF command. It is not clear about how to turn it into XT protocol, XT reset is needed perhaps.

TMK converter communicates with the keyboard on AT protocol.

Keyboard ID: AB83

Debug log
ERR:40 ISR:AA90
ERR:40 ISR:AA90
...
ERR:40 ISR:AA90
ERR:40 ISR:AA90
ERR:40 ISR:AA90 A3230 wFF ISR:5520 rFA rAA W3299 wF2 b:FAAB rFA rAB r83 R3809
ID:AB83(AT) S3810 wED rFA w02 rFA L3821
https://geekhack.org/index.php?topic=103648.msg3047128#msg3047128
TMK:8ad6bfa2/LUFA


USB configured.

Keyboard start.

ERR:40 ISR:AA90
PRT:10 ISR:0000 I223
PRT:10 ISR:0000 rAA A224 wFF rFA rAA W295 wF2 b:FAAB rFA rAB r83 R805
ID:AB83(AT) S805 wED rFA w00 rFA L822
Device disconnected.
Waiting for new device:..
Listening:


TMK:8ad6bfa2/LUFA


USB configured.

Keyboard start.

ERR:40 ISR:AA90
PRT:10 ISR:0000 I419
ERR:40 ISR:AA90
PRT:10 ISR:0000 !FULL! rFF A420 wFF rFA rAA W491 wF2 b:FAAB rFA rAB r83 R1001
ID:AB83(AT) S1002 wED rFA w00 rFA L1018
https://geekhack.org/index.php?topic=103648.msg3047679#msg3047679

Siemens F500

Auto-switching behaviour is not confirmed.

As of 2023-06 it is recognized as normal AT keyboard and works with TMK IBMPC converter. Soarer’s converter works in XT protocol reportedly.

Debug log
TMK:b604da/LUFA:d6a7df

USB configured.

Loop start.
I2500 I2500 
2501 PRT:10 ISR:EA90 rAA A5501 wFF rFA A5504 wFF R R R R R R R R R R rAA W6213 
6213 ERR:11 ISR:8000 wF2 rFA rAB r83 R6719 
ID:AB83(AT) S6719 wED rFA w02 rFA L6726 X6726 

rE0 r12 rE0 r00 rE0 rF0 r00 rE0 rF0 r12

The keyboard was recoginized as XT with TMK IBMPC converter as of 2020-11. https://geekhack.org/index.php?topic=103648.msg2984619#msg2984619

IBM Enhanced Keyboard

Some of Model M IBM Enhanced keyboards is known to be compatible to both AT and XT protocol.

PS/2 Mode 1 and Mode 2

Keyboard Mode Selection

The keyboard modes establish the line protocol needed for the keyboard to communicate with the host system. Based on the signals found on the keyboard 'clock' and 'data' lines immediately following POR, the keyboard selects either Mode 1 or Mode 2 for communication with the attached system unit.

The following describes the keyboard 'clock' and 'data' signal conditions necessary to establish each mode.

If the 'clock' line is active (high) immediately after POR, the keyboard sets up for Mode 1 operation. It then waits for the 'clock' line to become inactive (low), executes the basic assurance test (BAT), and returns the completion code. If the 'clock' line is inactive (low) immediately after POR, the keyboard executes the BAT, waits for the 'clock' line to become active (high), and sends the completion code in Mode 2 protocol. If the system has not made the 'data' line inactive within 40 microseconds, Mode 2 operation is established. If the 'data' line has become inactive within this time, Mode 1 is established.

Mode 1 uses scan code set 1 only. Mode 2 uses scan code set 2, but can be switched to scan code set 1 or scan code set 3 using the Select Alternate Scan Codes command. Note: After the mode is set, it can be changed only by another 'power-on-reset.'

P.4-4 IBM 7531/7532 Technical Reference

where Mode 1 indicates XT protocol and Mode 2 does AT.

Industrial version and some version of Model M are supposed to support both XT and AT.

IBM 1391401

Controller board: 1392993

Just tested briefly but this keyboard doesn’t seems to support the protocol switching. 2021-09-14

Discussions

Commodore PC 30/40 III

In fact, I’ve got an 102-key IBM PS/2 keyboard (Model M, 1391409) from 1991, and it actually worked in my early-BIOS XT too! However, as expected, the LED’s doesn’t work.

Notes

Confusing historical Keys

SysRq

The key was introduced as a dedicated key on AT(84-key) keyboard and assinged to scan code 0x84. The SysRq key dispappeared and remained as sub legend of PrintScreen key on Enhanced(101-key) keyboard later.

TMK converter translates the key into PrintScreen on USB HID.

KeyPad* / PrtScr

The key exists on PC/XT(83-key) and AT(84-key) keyboard but not on Enhanced keyboard. Main role of the key is Keypad* and recognized as PrintScreen funtion by computer of those days when modified with Shift. This key should be recognized just as Keypad* on modern computer, and it doesn’t act as PrintScreen anyway.

TMK converter translates the key into Keypad* on USB HID.

Pull-Up Resistor

Pull-up resistors of 1-4.7K Ohm on both Data and Clock line are strongly recommended, without them it won’t work in some cases.

Keyboard                                       MCU(AVR)
   -----.                                      ,-----.
      5V|------------------------------+--+----|VCC  |
        |                              |  |    |     |
        |                              R  R    |     |
        |                              |  |    |     |
    DATA|------------------------------|--+----|PD0  |
   CLOCK|------------------------------+-------|PD1  |
        |                                      |     |
     GND|--------------------------------------|GND  |
   -----'                                      `-----'
R: 1K-4.7K Ohm resistor
Clone this wiki locally