Keyboard Scancodes
- Updated 30th March 2024
This page covers the codes that are transmitted from the keyboard to host via their carrier protocol. 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.
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 scancode set 1: IBM Personal Computer Keyboard (5150, 5155 & 5160)
- 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 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 scancode set 1
IBM scancode set 1 (sometimes called "XT" scancodes) was the first of the 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. Fully-compliant PS/2 keyboards should also be able to output set 1 scancodes when told to using the Select Alternate Scan Codes command. As standard, most keys should transmit make and break codes. These scancodes were typically transmitted via the serial-based 9-bit "XT-style" keyboard interface, but using the aforementioned command on compliant PS/2 keyboards will result in them being transmitted via the 11-bit "AT-style" keyboard interface (which wouldn't be compatible with an standard XT/XT-clone PC).
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
- 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. These scancodes are transmitted via the serial-based 11-bit "AT-style" keyboard interface. Set 2 scancodes and the AT-style interface were reused for PS/2's standard functionality albeit with a different (but compatible with a simple adapter) plug.
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. These scancodes are transmitted via the serial-based 11-bit "AT-style" keyboard interface although set 3 isn't natively compatible with PC/AT, PS/2 and clone computers that aren't compatible with Linux or Windows NT 3.5 and later due to the differences outside the aforementioned similar codes and default make-and-break behaviour.
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