Home Page Keyboard Scan Codes shopping cart
site currency

currency info
spacer Home spacer Barcode Mill spacer Barcode Fonts spacer How to order spacer Email us spacer
.
.
 

PC Keyboard Scan Codes

News: Keyboard Emulator now on-line

You can now determine specific Keyboard Scancodes and sequences without the need to look them up individually in a table and assemble them by hand. Just click on the keys and cut and paste the results. The Keyboard Emulator is here


Note dated January 2003

The XT scancodes and the 84 key keyboard mentioned in the following text refer to obsolete equipment. There may be some special purpose equipment still using XT codes? Some Electronic PC board level products were known to use XT codes maybe some still do?

It’s easy to get confused over scancodes because the AT scancodes used at the hardware level are converted by the PC Bios into XT codes. If you are an engineer looking at the keyboard bus lines with a ’scope or 'Reverse Mule' analysis unit you will likely see AT style scancodes. But if you are a programmer you will probably be dealing with XT codes. This is to maintain backward compatibility with the earliest PCs of the mid 1980s. If anyone knows of any equipment still using XT codes at the hardware level please let me know.

Since this page was first written six new keys have been added to the original keyboards. The scancodes for these keys can be found at the foot of this page. The Mule can emulate ALL the new keys.

All the scancodes published here have been verified with The Shadow Mule and are known to be accurate. Data published elsewhere is often seen to contain errors. Please do not copy this data into another medium or web site. It is maintained up to date here and we strictly enforce our copyrights. We are happy for any site to link here.


Overview

The PC keyboard interface is designed so the system software has maximum flexibility in defining certain keyboard operations. This is accomplished by having the keyboard return scancodes rather than ASCII codes. Each key generates a 'make' scancode when pressed and a 'break' scancode when released. The computer system interprets the scancodes to determine what operation it is to perform. For historical compatibility reasons computers can employ different sets of scancodes for different purposes. Earlier PC computers tend to use the XT scancode set. Current PC computers tend to use the AT scancode set. The MF1, MF2 and MF3 sets are alternatives, similar in many respects to the XT and AT sets. The table below shows the scancodes generated when a key is pressed- the 'make' code. The 'break' code may be derived from the 'make' code as described later. Notice that scancodes may consist of a single or several bytes.

Many keyboard scancode tables published are not completely accurate. Confusion arises between scancodes issued by the keyboard hardware and the scancodes appearing in the keyboard buffer. The scancodes presented here are those actually sent by the keyboard hardware. The computer BIOS may translate the code for compatibility reasons. For example, the XT scancode set was first used in the original IBM PC computer. Other IBM computers and terminals used a different scancode set. Apparently IBM tried to bring the PC into line with its other products when the IBM PC/AT was launched. The keyboard for that machine used a scancode set virtually identical to other IBM machines. However to maintain compatibility with earlier PC software the BIOS for the AT machines converted the AT scancodes into the earlier XT scancodes. At the current time (June 1995) this system of code conversion in the BIOS persists. The code you read from the keyboard buffer is not necessarily the same code transmitted from the keyboard.

How to Calculate the Scancode

  1. Use the keyboard sketches to determine the 'Key Number'. Note that the 102 key keyboard shown is the keyboard used in the UK. In the USA and some other countries a 101 key keyboard is used- there are minor scancode differences- read the table notes.
  2. Lookup the 'Key number' in the table and read of the 'Make'scancode. Note that the scancode differs depending on the scancode set currently in use. Note also that some scancodes consist of more than 1 byte.
  3. Calculate the 'break' scancode as detailed below

'Break' scancodes for PC/XT computers

The 'break' code for XT style computers is the 'Make' code OR’d with the hexadecimal value 80. (If you are unfamiliar with hexadecimal numbers then simply change the first character of the scancode thus: Change 0 to 8, 1 to 9, 2 to A, 3 to B, 4 to C, 5 to D, 6 to E, 7 to F)

For example the scancodes generated by pressing and releasing the Escape key (Key Number 110) are 01 81

'Break' scancodes for PC/AT computers

Most PC’s made since about 1989 use keyboards that generate AT scancodes (Though the codes may be converted to XT scancodes in the BIOS). The 'break' code for AT class scancodes is simply the 'make' code preceded by hex F0. For example the scancodes generated when the Escape key is pressed and released are 76 F0 76.

Special scancodes of potential interest to Altek Mule™ users

If the keyboard’s buffer overflows it sends a special scancode to the computer. This generally causes the computer to sound a warning beep. Altek Mule(tm) users may issue this code if they want to sound the beep to draw the operators attention. For computers using AT scancodes the code is 00. (For obsolete PCs using XT scancodes the code was hex FF)

PC Keyboard, 102 key

[Keyboard 102 keys]

PC Keyboard, 84 key

[Keyboard 84 keys]

Scancode Table

Table Notes

Key Num XT AT MF1 MF2 MF3
1290E290E0E
20216021616
3031E031E1E
40426042626
50525052525
6062E062E2E
70736073636
8083D083D3D
9093E093E3E
100A460A4646
110B450B4545
120C4E0C4E4E
130D550D5555
150E660E6666
160F0D0F0D0D
171015101515
18111D111D1D
191224122424
20132D132D2D
21142C142C2C
221535153535
23163C163C3C
241743174343
251844184444
26194D194D4D
271A541A5454
281B5B1B5B5B
* 292B5D2B5D5C
303A583A5814
311E1C1E1C1C
321F1B1F1B1B
332023202323
34212B212B2B
352234223434
362333233333
37243B243B3B
382542254242
39264B264B4B
40274C274C4C
412852285252
** 422B5D2B5D53
431C5A1C5A5A
442A122A1212
** 455661566113
462C1A2C1A1A
472D222D2222
482E212E2121
492F2A2F2A2A
503032303232
513131313131
52323A323A3A
533341334141
543449344949
55354A354A4A
573659365959
581D141D1411
603811381119
613929392929
62E038E011E038E01139
64E01DE014E01DE01458
75E052E070E052E07067
76E053E071E053E07164
79E04BE06BE04BE06B61
80E047E06CE047E06C6E
81E04FE069E04FE06965
83E048E075E048E07563
84E050E072E050E07260
85E049E07DE049E07D6F
86E051E07AE051E07A6D
89E04DE074E04DE0746A
904577457776
91476C476C6C
924B6B4B6B6B
934F694F6969
95E035E04AE035E04A77
964875487575
974C734C7373
985072507272
995270527070
100377C377C7E
101497D497D7D
1024D744D7474
103517A517A7A
1045371537171
1054A7B4A7B84
1064E794E797C
108E01CE05AE01CE05A79
1100176017608
1123B053B0507
1133C063C060F
1143D043D0417
1153E0C3E0C1F
1163F033F0327
117400B400B2F
1184183418337
119420A420A3F
1204301430147
121440944094F
1225778577856
123580758075E
124E02AE037E012E07CE02AE037E012E07C57
125467E467E5F
126E11D45E1
9DC5
1477F014
F077
E11D45E1
9DC5
E11477E1
F014F077
62

Windows 95 Update

When the 'Windows 95' operating system was introduced three new keys were added to the PC keyboard. These keys have been retained for all subsequent operating systems and PCs. They are the two 'Flying Windows' keys and the 'Pop Up Menu' key. These keys may be emulated by The Mule in Scancode Mode just like any other key. The appropriate 'make' and 'break' scancodes are shown below...

 

Make

Break

Left Flying Window

E0 1F

E0 F0 1F

Right Flying Window

E0 27

E0 F0 27

Pop Up Menu

E0 2F

E0 F0 2F

January 2003 Update

Some computers are appearing with 3 extra Power Management keys. These keys are used to support OnNow architecture PCs. (OnNow is a term for a PC that is always on but appears off and responds immediately to user or other requests.) The three keys are Power, Sleep and Wakeup. These keys are non repeating keys. In other words the 'Make' scancode is sent once regardless of how long the key is held down. These keys may be emulated by The Mule in Scancode Mode just like any other key. The appropriate 'make' and 'break' scancodes are listed below...

 

Make

Break

Power

E0 37

E0 F0 37

Sleep

E0 3F

E0 F0 3F

Wake Up

E0 5E

E0 F0 5E


Altek Instruments have designed and built a general purpose, low cost PC interface which generates Keyboard Scancodes. Any key or combination of keys may be emulated thus enabling any applications program to interact with RS232 peripheral devices. We call it The Mule™.

Altek Instruments Ltd have a range of products designed for the data collection/automatic ID industries.

.
.
Top Home            © Lee Allen, 2014