JS函数:获取按键keycode

获取按键

<script language="javascript">
  function  keyDown()
  {
    var keycode=event.keyCode;                
    var keychar=String.fromCharCode(keycode);    
    alert('ASCII='+keycode+'\nKeyChar='+keychar);  
  }
  document.onkeydown=keyDown; 
</script>

用ENTET代替TAB

<script language="javascript">
function  keyDown()
{
var  keycode=event.keyCode;
var  keyChar=String.fromCharCode(keycode);
if(keycode==13)
event.keyCode=9;
};
document.onkeydown=keyDown;
</script>

标签: js, keycode

仅有一条评论

  1. ning ning

    javascript:void(0)a

评论已关闭