2013-01-16 49 views

回答

2
<script type="text/javascript"> 
    function myKeyPress(e){ 

     var keynum; 

     if(window.event){ // IE     
      keynum = e.keyCode; 
     }else 
      if(e.which){ // Netscape/Firefox/Opera     
       keynum = e.which; 
      } 
     alert(String.fromCharCode(keynum)); 
    } 
    </script> 


<form> 
    <input type="text" onkeypress="return myKeyPress(event)" /> 
</form> 

How to find out what character key is pressed?

+0

非常感謝你,它適合我:) – user1854912

相關問題