INFO: Scan Codes for IBM and Compatible Keyboards

Last reviewed: August 26, 1997
Article ID: Q37617

The information in this article applies to:
  • Microsoft C for MS-DOS, version 6.0ax
  • Microsoft C for OS/2, versions 6.0, 6.0a
  • Microsoft C/C++ for MS-DOS, version 7.0
  • Microsoft Visual C++ for Windows, versions 1.0, 1.5
  • Microsoft Visual C++ 32-bit Edition, versions 1.0, 2.0, 4.0, 4.1, 5.0

SUMMARY

The table below presents the scan codes produced by IBM and compatible keyboards. All scan codes values are in hexadecimal. Please refer to the "IBM PC Technical Reference" manual for more details.

83 key (PC,PC/XT)  |   84 key (PC/AT)     |   101/102 key (PC/AT PS/2)
Key     Scan Code  |   Key     Scan Code  |   Key     Scan Code

ESC         01          KP ESC      01          ESC         01
1           02          1           02          1           02
2           03          2           03          2           03
3           04          3           04          3           04
4           05          4           05          4           05
5           06          5           06          5           06
6           07          6           07          6           07
7           08          7           08          7           08
8           09          8           09          8           09
9           0A          9           0A          9           0A
0           0B          0           0B          0           0B
-           0C          -           0C          -           0C
=           0D          =           0D          =           0D
BACKSPACE   0E          BACKSPACE   0E          BACKSPACE   0E
TAB         0F          TAB         0F          TAB         0F
Q           10          Q           10          Q           10
W           11          W           11          W           11
E           12          E           12          E           12
R           13          R           13          R           13
T           14          T           14          T           14
Y           15          Y           15          Y           15
U           16          U           16          U           16
I           17          I           17          I           17
O           18          O           18          O           18
P           19          P           19          P           19
[           1A          [           1A          [           1A
]           1B          ]           1B          ]           1B
RETURN      1C          RETURN      1C          RETURN      1C
CTRL        1D          CTRL        1D          L CTRL      1D
A           1E          A           1E          A           1E
S           1F          S           1F          S           1F
D           20          D           20          D           20
F           21          F           21          F           21
G           22          G           22          G           22
H           23          H           23          H           23
J           24          J           24          J           24
K           25          K           25          K           25
L           26          L           26          L           26
;           27          ;           27          ;           27
'           28          '           28          '           28
`           29          ESC         29          `           29
L SHIFT     2A          L SHIFT     2A          L SHIFT     2A
\           2B          \           2B          \           2B
Z           2C          Z           2C          Z           2C
X           2D          X           2D          X           2D
C           2E          C           2E          C           2E
V           2F          V           2F          V           2F
B           30          B           30          B           30
N           31          N           31          N           31
M           32          M           32          M           32
,           33          ,           33          ,           33
.           34          .           34          .           34
/           35          /           35          /           35
R SHIFT     36          R SHIFT     36          R SHIFT     36
PRT SCR     37          PRT SCR     37          KP *        37
ALT         38          ALT         38          ALT         38
Space       39          Space       39          Space       39
CAPS LOCK   3A          CAPS LOCK   3A          CAPS LOCK   3A
F1          3B          F1          3B          F1          3B
F2          3C          F2          3C          F2          3C
F3          3D          F3          3D          F3          3D
F4          3E          F4          3E          F4          3E
F5          3F          F5          3F          F5          3F
F6          40          F6          40          F6          40
F7          41          F7          41          F7          41
F8          42          F8          42          F8          42
F9          43          F9          43          F9          43
F10         44          F10         44          F10         44
NUM LOCK    45          NUM LOCK    45          NUM LOCK    45
SCROLL LOCK 46          SCROLL LOCK 46          SCROLL LOCK 46
KP 7        47          KP 7        47          KP 7        47
KP 8        48          KP 8        48          KP 8        48
KP 9        49          KP 9        49          KP 9        49
KP -        4A          KP -        4A          KP -        4A
KP 4        4B          KP 4        4B          KP 4        4B
KP 5        4C          KP 5        4C          KP 5        4C
KP 6        4D          KP 6        4D          KP 6        4D
KP +        4E          KP +        4E          KP +        4E
KP 1        4F          KP 1        4F          KP 1        4F
KP 2        50          KP 2        50          KP 2        50
KP 3        51          KP 3        51          KP 3        51
KP 0        52          KP 0        52          KP 0        52
KP .        53          KP .        53          KP .        53
                        Sys Req     54          F11         57
                                                F12         58
                                                R CTRL      E0 10
                                                KP /        E0 36
                                                R ALT       E0 38
                                                HOME        E0 47
                                                UP ARROW    E0 48
                                                PAGE UP     E0 49
                                                LEFT ARROW  E0 4B
                                                RIGHT ARROW E0 4D
                                                END         E0 4F
                                                DOWN ARROW  E0 50
                                                PAGE DOWN   E0 51
                                                INSERT      E0 52
                                                DELETE      E0 53
                                                KP ENTER    E0 1C
                                                PAUSE       E1 10 45
                                                PRINT SCR   E0 2A E037

Source: Norton's Guide to the IBM PC and PS/2
Keywords          : VCGenIss kbfasttip
Version           : MS-DOS:6.00ax,7.0; OS/2:6.0,6.00a; WINDOWS:1.0,1.5;  WINDOWS NT:1.0,2.0,4.0,4.1,5.0
Platform          : MS-DOS NT OS/2 WINDOWS
Issue type        : kbref kbinfo


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 26, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.