js获取每个按键的ASCII值
通过js绑定键盘按下事件onkeydown获取每个按键的ascII值。
js获取每个按键的ascii值
<script language="javascript"> //获取每个按键的值 function keyDown() { var keycode=event.keyCode; var keychar=String.fromCharCode(keycode); console.log('ASCII='+keycode+'\nKeyChar='+keychar); } document.onkeydown=keyDown; </script>
用ENTET代替TAB进行切换
<script language="javascript"> //用ENTER代替TAB function keyDown() { var keycode=event.keyCode; var keyChar=String.fromCharCode(keycode); if(keycode==13) event.keyCode=9; }; document.onkeydown=keyDown; </script>