Javascript examples for DOM:Key Event
detecting the keypress in javascript for IE, Netscape/Firefox/Opera
<html> <head> <script type="text/javascript"> function getKeystroke(e){//w w w. j a va 2 s . co m var keystroke; if(window.event){ // IE keystroke = e.keyCode; }else if(e.which){ // Netscape/Firefox/Opera keystroke = e.which; } console.log(String.fromCharCode(keystroke)); } </script> </head> <body> <form> <input type="text" onkeypress="getKeystroke(event)"> </form> </body> </html>