Js获得键盘码(IE/FF)

 function keyUp(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;

 

 

 function text(event){
   var browser;
      if (document.all) 
          browser = "IE"; 
      else 
          browser = "FF";
      if(browser == "IE"){ 
          key = event.keyCode; 
      }else{  
          key=event.which;
      }
   alert(key); 
  }

 

 

 

你可能感兴趣的:(IE)