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”
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/8726.html