IE和火狐下获取键盘按下事件 window.event.keyCode window.event.which

<script type="text/javascript">
document.onkeydown = function (e){  
var theEvent = window.event || e;  
var code = theEvent.keyCode || theEvent.which;  
document.getElementById("result").innerHTML += code +" ";
}
</script>
比对结果:<span id="result"></span>
 

把以上代码复制到页面中即可运行!

ps:
IE6中获取ANSI方法为:window.event.keyCode
火狐:window.event.keyCode||window.event.which

你可能感兴趣的:(keycode)