本附录中的各表列举了键盘按键扫描码和其ASCII码之间的对照关系,表中数据都是十六进制形式。

在用中断16H的0号功能时,当按下任意一个键或组合键时,寄存器AH和AL分别保存着该按键的扫描码和ASCII码。

表1、ASCII码的编码方案

高位 | 低位000001010011100101110111
0000NULDELSP0@P`p
0001SOHDC1!1AQaq
0010STXDC22BRbr
0011ETXDC3#3CScs
0100EOTDC4$4DTdt
0101ENQNAK%5EUeu
0110ACKSYN&6FVfv
0111BELETB7GWgw
1000BSCAN(8HXhx
1001HTEM)9IYiy
1010LFSUB*:JZjz
1011VTESC'+;K[k{
1100FFFS<L/l|
1101CRGS-=M]m}
1110SORS.>N^n~
1111SIUS/?O_oDel

表2、字母和空格按键的编码表

按 键单 键SHIFTCTRLALT
按 键扫描码ASCII码扫描码ASCII码扫描码ASCII码扫描码ASCII码
a and A1E611E411E011E00
b and B3062304230023000
c and C2E632E432E032E00
d and D2064204420042000
e and E1265124512051200
f and F2166214621062100
g and G2267224722072200
h and H2368234823082300
i and I1769174917091700
j an1 J246A244A240A2400
k and K256B254B250B2500
l and L266C264C260C2600
m and M326D324D320D3200
n and N316E314E310E3100
o and O186F184F180F1800
p and P1970195019101900
q and Q1071105110111000
r and R1372135213121300
s and S1F731F531F131F00
t and T1474145414141400
u and U1675165516151600
v and V2F762F562F162F00
w and W1177115711171100
x and X2D782D582D182D00
y and Y1579155915191500
z and Z2C7A2C5A2C1A2C00
SpaceBar3920392039203920

表3、功能键的编码表

按 键单 键SHIFTCTRLALT
按 键扫描码ASCII码扫描码ASCII码扫描码ASCII码扫描码ASCII码
F13B0054005E006800
F23C0055005F006900
F33D00560060006A00
F43E00570061006B00
F53F00580062006C00
F64000590063006D00
F741005A0064006E00
F842005B0065006F00
F943005C0066007000
F1044005D0067007100
F118500870089008B00
F12860088008A008C00

表4、数字键盘的编码表

按 键单 键SHIFTCTRLALT
按 键扫描码ASCII码扫描码ASCII码扫描码ASCII码扫描码ASCII码
Ins & 0520052309200
End & 14F004F3175000001
↓ & 25000503291000002
PgDn & 35100513376000003
← & 44B004B3473000004
54C004C358F000005
→ & 64D004D3674000006
Home & 74700473777000007
↑ & 8480048388D000008
PgUp & 94900493984000009
+4E2B4E2B90004E00
-4A2D4A2D8E004A00
Del & ‘.’5300532E9300
*372A372A96003700

表5、第一排数字键盘的编码表

单 键SHIFTCTRLALT
按 键扫描码ASCII码扫描码ASCII码扫描码ASCII码扫描码ASCII码
` and ~2960297E2900
1 and !023102217800
2 and @0332034003007900
3 and #043304237A00
4 and $053405247B00
5 and %063506257C00
6 and ^0736075E071E7D00
7 and &083708267E00
8 and *0938092A7F00
9 and (0A390A388000
0 and )0B300B298100
- and _0C2D0C5F0C1F8200
= and +0D3D0D2B8300

表6、操作按键的编码表

按 键单 键SHIFTCTRLALT
按 键扫描码ASCII码扫描码ASCII码扫描码ASCII码扫描码ASCII码
Esc011B011B011B0100
Backspace0E080E080E7F0E00
Tab0F090F009400A500
Enter1C0D1C0D1C0A1C

表7、标号按键的编码表

按 键单 键SHIFTCTRLALT
按 键扫描码ASCII码扫描码ASCII码扫描码ASCII码扫描码ASCII码
[ and {1A5B1A7B1A1B1A00
] and }1B5D1B7D1B1D1B00
; and :273B273A27
’ and "2827282228
/ and |2b5C2b7C2B1C2b
, and <332C333C33
. and >342E343E34
/ and ?352F353F35

表8、附加按键的编码表

按 键单 键SHIFTCTRLALT
按 键扫描码ASCII码扫描码ASCII码扫描码ASCII码扫描码ASCII码
Slash(/)E02FE02F950A400
EnterE00DE00DE00AA600
Home47E047E077E09700
End4FE04FE075E09F00
PageUp49E049E084E09900
PageDown51E051E076E0A100
DnArrow50E050E091E0A000
LeftArrow4BE04BE073E09B00
RightArrow4DE04DE074E09D00
UpArrow48E048E08DE09800
Ins52E052E092E0A200
Del53E053E093E0A3

表9、其它按键的扫描码

当这些键被按下时,BIOS并没有把它们的扫描码输入键盘缓冲区。

按 键扫描码
CapsLock3A
NumLock45
ScrollLock46
Shift(Left)2A
Shift(Right)36
Alt38
Ctrl1D
PrtScreen37
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐