js中对按键的监听

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

js中,实现对键盘按键的监听:

function keyUp> 这里输入引用文本p(e) {   
       var currKey=0,e=e||event;   
       currKey=e.keyCode||e.which||e.charCode;   
       var keyName = String.fromCharCode(currKey);   
       alert("按键码: " + currKey + " 字符: " + keyName);   
   }   
document.onkeyup = keyUp;

alert信息例如:"按键码: 81 字符: Q"