分享一段简单的获取键盘编码的程序:
<!DOCTYPE html>
<html>
<head>
<script>
function whichButton(event)
{
alert(event.keyCode);
}
</script>
</head>
<body οnkeyup="whichButton(event)">
<p><b>Note:</b> Make sure the right frame has focus when trying this example!</p>
<p>Press a key on your keyboard. An alert box will alert the keycode of the key.</p>
</body>
</html>
这段代码虽然短小,但是精悍!有木有发现它获取键盘敲击事件是用“onkeyup”来捕捉的,而不是我们一般常见的“onkeypress”和"onkeydown"!!如果捕捉“按压”,不同的浏览器还用了不同的事件,据我了解,Firefox、Opera用onkeypress、IE、Chrome用onkeydown,而且据网上说“Shift、Ctrl、Alt、F1、F2、...等按键是不会产生onKeyPress事件的”。所以以后我们来捕捉键盘事件,你懂得..
![大笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/laugh.gif)