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>

posted on 2014-07-09 11:09  _故乡的原风景  阅读(116)  评论(0编辑  收藏  举报