Keyboard Scancodes
- Updated 16th January 2025
This page covers keyboard scancodes, typically hexadecimal codes that are transmitted from the keyboard to host via their carrier protocol to indicate what keys the user is pressing. Note that protocol (the specifics of the connection) and scancodes (the data transmitted via that connection) are distinct parts of how a keyboard communicates. This topic is organised by the scancode set itself as major sections with subsections for individual implementations and notes on any idiosyncrasies or nuances.
Note
The keyboard diagrams used throughout this page are best viewed on desktop and presently requires JavaScript to be enabled to work.
Contents
- IBM 5251/5252 scancodes: IBM 5251/5252 Typewriter Keyboard
- IBM 5251/5252 scancodes: IBM System/23 Datamaster Keyboard (5322 & 5324)
- IBM 5251/5252 scancodes: IBM 5291/5292 Typewriter Keyboard
- IBM 3290-1/5085 scancodes: IBM 104-key Converged Keyboard (3290-1/5085)
- IBM 3290-1/5085 scancodes: IBM 24-key Numeric or Program Function Keypad (3290-1/5085)
- IBM 4704 scancodes: IBM 4704 Model 100 Function Keyboard
- IBM 4704 scancodes: IBM 4704 Model 200 Alphameric Keyboard
- IBM 4704 scancodes: IBM 4704 Model 300 Expanded Alphameric Keyboard
- IBM 4704 scancodes: IBM 4704 Model 400 Administrative Keyboard
- IBM 4704 scancodes: IBM 4704 102-key Chinese/Japanese Keyboard
- IBM scancode set 1: IBM Personal Computer Keyboard (5150, 5155 & 5160)
- IBM scancode set 1: IBM PCjr Cordless Keyboard
- IBM scancode set 1: IBM JX Cordless Keyboard
- IBM scancode set 1: IBM Enhanced Keyboard (Personal Systems)
- IBM scancode set 1: IBM PS/2 Host Connected Keyboard (Personal Systems)
- IBM scancode set 2: IBM Personal Computer AT Keyboard (5170)
- IBM scancode set 2: IBM Enhanced Keyboard (Personal Systems)
- IBM scancode set 2: IBM PS/2 Host Connected Keyboard (Personal Systems)
- IBM scancode set 3: IBM 122-key Converged Keyboard (3179/3180/319X/3290-2/347X/348X/527X) & PS/2 Host Connected Keyboard (Personal Systems)
- IBM scancode set 3: IBM Enhanced Keyboard (3151/316X/319X/347X/348X)
- IBM scancode set 8Ah: IBM 5556 Type 1 & 2 Multistation 124-key Keyboard
- IBM scancode set 8Ah: IBM 5576 Type 2 PS/55 106-key Keyboard
IBM 5251/5252 scancodes
These scancodes (no official name known) were believed to be introduced in 1977 with the IBM 5251 Display Station and 5252 Dual Display Station keyboards and reused by some later terminals and computers. Only some keys transmit make and break codes and the keyboard's typematic capability varies between implementation. These scancodes were typically transmitted via a specific parallel-based interface.
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- * Non-typematic key.
- ** Both make & break and non-typematic key.
- For make & break keys, the first bit of the binary scancode is used to indicate the state of the key. For example, the hex
54
scancode in binary is01010100
, but its first digit (the start bit) can be a 0 to indicate the key has been pressed or a 1 to indicate the key has been released. All non make & break keys will always have a start bit of 0. - Source: IBM SY31-0461-0 (PDF page 54)
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- * Make & break key.
- ** Typematic key.
- Source: IBM SY34-0171-0 (PDF page 84)
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- * Non-typematic key.
- ** Both make & break and non-typematic key.
- Source: IBM SY31-0644-0 (PDF page 171)
IBM 3290-1/5085 scancodes
These scancodes (no official name known) were believed to be introduced in 1983 with the IBM 3290 Model 1 Information Panel and reused with the IBM 5080 Graphics System's 5085 Graphics Processor. They were the scancodes used by the original design of the IBM Converged Keyboard - Type 1 104-key Model Fs. These scancodes were typically transmitted via a specific parallel-based interface.
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- Any key with two scancodes is a make & break key.
- Source: IBM SY66-0101-3 (PDF page 91)
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- Source: IBM SY66-0101-3 (PDF page 90)
IBM 4704 scancodes
These scancodes (no official name known) are believed to be exclusive to the IBM 4704 Display Station for the IBM 4700 Finance Communication System. These scancodes were transmitted via a specific serial-based interface.
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- Source: TMK (ibm4704_usb)
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- The two keys either side of the spacebar (typically Alt keys) always share the same scancode as per design, thus a host system or USB converter cannot distinguish between them.
- Source: TMK (ibm4704_usb)
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- The two keys either side of the spacebar (typically Alt keys) always share the same scancode as per design, thus a host system or USB converter cannot distinguish between them.
- Source: TMK (ibm4704_usb)
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- The two keys either side of the spacebar (typically Alt keys) always share the same scancode as per design, thus a host system or USB converter cannot distinguish between them.
- Source: TMK (ibm4704_usb)
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- Source: TMK (ibm4704_usb)
IBM scancode set 1
IBM scancode set 1 (sometimes called "XT" scancodes) was the first of the main 3 numbered scancode sets introduced by IBM in the 1980s. They were introduced with the IBM 5150 Personal Computer and also reused by IBM 5155 Portable Personal Computer and 5160 Personal Computer XT. These scancodes were typically transmitted via the serial-based IBM PC Mode 1 protocol (at least for the non-cordless keyboards that used set 1). The "Enhanced" variant of the IBM PC Mode 2 protocol can be instructed to transmit set 1, but this would only allow the keyboard to work with software that expects set 1 input, and not for computers that expect an IBM PC Mode 1 compatible keyboard.
A typical make or break code is a 1-byte hexadecimal value. For keys unique to the IBM Enhanced Keyboard over the IBM Personal Computer AT Keyboard, 2 bytes of values may be sent instead, with the first one being E0
. If present, the Pause key uniquely sends 6 bytes of values as its make event and never sends a break code. A given break code is 1 or 2 bytes of values depending on whether E0
is present, and the break code will be the make code plus 0x80
. For example:
- The spacebar sends
39
as a make code, thus its break code will beB9
. - The up key on an IBM Enhanced Keyboard sends
E0 48
as a make code, thus its break code will beE0 C8
.
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- Source: TMK
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- The keyboard will send scancode
55
when it detects ghosting (phantom-key detection). This scancode would then be used by the host IBM PCjr to know when to ignore key presses. - Source: IBM PCjr Technical Reference
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- Source: IBM JX Technical Reference
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- All Enhanced Keyboards for Personal Systems (PS/ValuePoint, PS/1, PS/2, etc.) are IBM scancode set 2 default keyboards. To access IBM scancode set 1 capability, you need to use PS/2's Select Alternate Scan Codes command.
- Using the aforementioned command will result in such scancodes being sent in PS/2 Mode 2 (11-bit AT-style) interface. To send set 1 scancodes in PS/2 Mode 1 (9-bit XT-style) interface, the Enhanced Keyboard in question also needs to support a special 'auto-sensing' capability. It's believed to only be a feature of earlier Enhanced Keyboards such as P/Ns 1388032, 1390120, 1390131 and their non-US English counterparts.
- Normally, there is no scancode (or even membrane assembly contact pads) for the disused barrel under the spacebar except for Lexmark-made Erase-Eaze keyboards.
- The Print Screen key's scancode changes when Alt is held.
- The Pause key's scancode changes when Ctrl is held. The Pause key also never sends a break code on release.
- All other keys prefixed with "E" may send fake Shift scancodes. You may notice the scancode that follows the letter are the same as other keys that have related functionality - for example, the arrow keys' prefixed scancodes are based on that of their numeric keypad counterparts.
- Source: John Elliott (see for more commentary on what the 'E-keys' do)
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- PS/2 Host Connected Keyboards are IBM scancode set 2 default keyboards. To access IBM scancode set 1 capability, you need to use PS/2's Select Alternate Scan Codes command.
- Using the aforementioned command will result in such scancodes being sent in PS/2 Mode 2 (11-bit AT-style) interface. It's presently unknown if these keyboards support the PS/2 Mode 1 (9-bit XT-style) interface.
- The Attn/SysRQ key's scancode changes when Alt is held.
- The Pause/ErInp key's scancodes change when Ctrl is held.
- The Print/PrtSc key's scancodes change when any Shift, Ctrl or Alt key is held.
- The NumLk/ScrLk key's scancode changes when Shift is held.
- The Space/Slash/Break key's scancode changes when Ctrl is held.
- All other keys prefixed with "E" may send fake Shift scancodes. You may notice the scancode that follows the letter are the same as other keys that have related functionality - for example, the arrow keys' prefixed scancodes are based on that of their numeric keypad counterparts.
- Source: John Elliott (see for more commentary on what the 'E-keys' do)
IBM scancode set 2
IBM scancode set 2 (sometimes called "AT" scancodes) was chronologically the last of the three numbered scancode sets introduced by IBM in the 1980s. It was introduced in 1984 with the IBM 5170 Personal Computer AT and its Model F keyboard, which means despite being a lower number, IBM scancode set 3 actually predates it by several months. Sets 2 and 3 are also very similar in that they (at least) share alphabet, number row, core numeric keypad, Enter/Return key, Shift key, Tab key and spacebar key codes, but diverge in other areas. These scancodes are transmitted via the "AT" (exclusively) and "Enhanced" (by default) variants of the serial-based IBM PC Mode 2 protocol.
A typical make code is a 1-byte hexadecimal value. For keys unique to the IBM Enhanced Keyboard over the IBM Personal Computer AT Keyboard, 2 bytes of values may be sent instead, with the first one being E0
. If present, the Pause key uniquely sends 8 bytes of values with break events integrated into its scancode sequence. A given break code is 2 or 3 bytes of values depending on whether E0
is present, with the first or second byte being F0
. For example:
- The spacebar sends
29
as a make code, thus its break code will beF0 29
. - The up key on an IBM Enhanced Keyboard sends
E0 75
as a make code, thus its break code will beE0 F0 75
.
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- Source: John Elliott
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- All Enhanced Keyboards for Personal Systems (PS/ValuePoint, PS/1, PS/2, etc.) are IBM scancode set 2 default keyboards. As such, they should be natively compatible with an AT/AT-clone or PS/2-compatible PC.
- Normally, there is no scancode (or even membrane assembly contact pads) for the disused barrel under the spacebar except for Lexmark-made Erase-Eaze keyboards.
- The Print Screen key's scancode changes when Alt is held.
- The Pause key's scancode changes when Ctrl is held. The Pause key also never sends a break code on release.
- All other keys prefixed with "E" may send fake Shift scancodes. You may notice the scancode that follows the letter are the same as other keys that have related functionality - for example, the arrow keys' prefixed scancodes are based on that of their numeric keypad counterparts.
- Source: John Elliott (see for more commentary on what the 'E-keys' do)
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- PS/2 Host Connected Keyboards are IBM scancode set 2 default keyboards. As such, they should be natively compatible with any AT/AT-clone or PS/2-compatible PC.
- The Attn/SysRQ key's scancode changes when Alt is held.
- The Pause/ErInp key's scancodes change when Ctrl is held.
- The Print/PrtSc key's scancodes change when any Shift, Ctrl or Alt key is held.
- The NumLk/ScrLk key's scancode changes when Shift is held.
- The Space/Slash/Break key's scancode changes when Ctrl is held.
- All other keys prefixed with "E" may send fake Shift scancodes. You may notice the scancode that follows the letter are the same as other keys that have related functionality - for example, the arrow keys' prefixed scancodes are based on that of their numeric keypad counterparts.
- Source: John Elliott (see for more commentary on what the 'E-keys' do)
IBM scancode set 3
IBM scancode set 3 was chronologically the second of the three numbered scancode sets introduced by IBM in the 1980s. It was introduced by 1983 with the IBM 3270 Personal Computer and its 122-key Model F Converged Keyboard, beating the IBM Personal Computer AT Keyboard and IBM scancode set 2 to market. Sets 2 and 3 are very similar in that they (at least) share alphabet, number row, core numeric keypad, Enter/Return key, Shift key, Tab key and spacebar key codes, but diverge in other areas. These scancodes are transmitted via the "terminal" (exclusively) and "Enhanced" (not by default) variants of the serial-based IBM PC Mode 2 protocol, although set 3 is not natively compatible with PC/AT, PS/2 and clone computers that are not compatible with Linux or Windows NT 3.5 and later due to the differences outside the aforementioned similar codes and default make/break behaviour mentioned below.
All make codes are 1-byte hexadecimal values. A given break code is 2 bytes of values, with the first byte being F0
. By default, only some keys will send break codes, hence such keys are already maked with F0
on the scancode diagrams below. The versions of the IBM PC Mode 2 protocol that support IBM scancode set 3 will also support system-to-keyboard commands that can alter this behaviour, enabling break codes for all keys or a selection of keys. For example, the spacebar sends 29
as a make code, thus its break code will be F0 29
.
Set 1 make/break behaviour
Break codes are always sent except by for Pause keys, and the code used will be the make code plus 0x80
. For example:
- The spacebar sends
39
as a make code, thus its break code will beB9
. - The up key on an IBM Enhanced Keyboard sends
E0 48
as a make code, thus its break code will beE0 C8
.
IBM 122-key Converged Keyboard (3179/3180/319X/3290-2/347X/348X/527X) & PS/2 Host Connected Keyboard (Personal Systems)
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- Only keys with a preceding
F0
scancode are a make & break key. A specific host-to-keyboard command has to be used to tell the keyboard to produce break codes for all keys. - Applies to 122-key Model Fs and (non-USB) 122-key Model Ms alike.
- Should also apply to Type 2 104-key Model Fs (for IBM 3290 Model 2 Information Panels only) as well (just ignore the numeric keypad area).
- 104-key (Type 2) and 122-key Converged Keyboards for IBM Display Stations (3179, 3180, 319X, 3290 Model 2, 527X, 347X InfoWindow and 348X InfoWindow II) are IBM scancode set 3 keyboards with no ability to change to set 1 or 2 scancodes. PS/2 Host Connected Keyboards are IBM scancode set 2 default keyboards - to access IBM scancode set 3 capability on those, you need to use PS/2's Select Alternate Scan Codes command.
- Source: TMK
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- * Keys reused from the Converged Keyboard layout that aren't in the same location. For example,
57
and5F
were originally F23 and F24 respectively on IBM Converged Keyboards despite being located where a PC-style keyboard's Print Screen and Scroll Lock keys are. As such, for software or active USB converters designed specifically for 122-key IBM scancode set 3 keyboards, all these keys may be mapped to unexpected functions by default. - Only keys with a preceding
F0
scancode are a make & break key. A specific host-to-keyboard command has to be used to tell the keyboard to produce break codes for all keys. - Enhanced Keyboards for IBM Display Stations (3151, 316X, 319X, 347X InfoWindow and 348X InfoWindow II) are IBM scancode set 3 keyboards with no ability to change to set 1 or 2 scancodes. All Enhanced Keyboards for Personal Systems (PS/ValuePoint, PS/1, PS/2, etc.) are IBM scancode set 2 default keyboards - to access IBM scancode set 3 capability on those, you need to use PS/2's Select Alternate Scan Codes command.
- Normally, there is no scancode (or even membrane assembly contact pads) for the disused barrel under the spacebar except for Lexmark-made Erase-Eaze keyboards.
- Source: John Elliott and TMK
IBM scancode set 8Ah
IBM scancode set 8Ah was a unique scancode set used by computers based within the 1983-launched IBM 5550 Multistation series, developed in Japan for domestic use and sometimes exported elsewhere in the Far East. Their IBM 5556 family keyboards Type 1 (5556-001) and Type 2 (5556-002) and variants of both are believed to natively use IBM scancode set 8Ah. IBM based some terminals on the Multistation design including the IBM 3194 Model H50 Display Station (IBM 3270 family) and IBM 5295 Display Station (IBM 5250 family) that also used keyboards derived from 5556 Type 1 and 2. At least some IBM 5576 (Personal System/55) keyboards support IBM scancode set 8Ah on some level, including IBM 5576 family keyboard Type 2 (5576-002). It's unclear if its use is triggered automatically on connection to a compatible host, or that it's something accessed via KDOS only. For 5556, the scancodes are believed to be transmitted via the serial-based 11-bit "AT-style" keyboard interface.
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- Source: IBM
Visualisation due to be loaded. If nothing appears, please ensure JavaScript is enabled.
Notes
- Source: akm