onkeydown : 用户按下一个键盘按键时发生
onkeypress : 在键盘按键按下并释放一个键时发生
onkeyup : 在键盘按键松开时发生
keyCode : 返回onkeypress,onkeydown或onkeyup事件触发的键的值的字符代码,或键的代码
eg:
代码:
<body><input type="text" id="input"><script>var input =document.getElementById("input")input.onkeydown=function(event){console.log(event.keyCode)if(event.keyCode==82){console.log("放下")}}input.onkeypress =function(){console.log("press")}input.onkeyup =function(){console.log("放开")}</script></body>

