Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get which key is pressed in 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));
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #key #pressed #javascript
ADD COMMENT
Topic
Name
9+8 =