从这个链接:http://www.javascriptkit.com/jsref/eventkeyboardmouse.shtml
Be careful when accessing the keyCode
property during an onkeydown or
onkeyup event,as it is set whenever
any key is pressed,including non
character keys like “Shift”. This
means if you try to press “Shift+a” to
try and get the keyCode for “A”,you
will always end up getting two
keyCodes instead,one for “Shift” and
one for “A” in that order. What you
won’t get regardless is the keyCode
for “a”,as keyCode always returns
the unicode value of the uppercase
version of a character
>按Shift键计为单个按键事件.
>当按下键时,按Shift键计为两个键控事件,释放键时键入两个键盘事件.
> keypress返回一致按下的一个或多个键的复合值.
> keydown和keyup返回单个键的值,同时忽略任何键组合.
现在这里是令人困惑的部分:由于某种原因,a键的未移位值作为键代码65返回.但是65表是ASCII表中的大写A.所以在某个地方,浏览器采用小写字母a(ASCII码97),将其转换为大写字母A,然后将keydown / keyup作为非移位字符传递.很奇怪,不是吗?