A cross-browser solution to get the Unicode value of the pressed keyboard key:
<!DOCTYPE html> <html> <body> <input type="text" size="40" onkeypress="myFunction(event)"> <p id="demo"></p> <script> function myFunction(event) {/* w w w . j a v a2 s . c o m*/ // Use charCode if the browser supports it, otherwise use event.keyCode for IE8 and earlier var x = event.charCode || event.keyCode; document.getElementById("demo").innerHTML = "The Unicode value is: " + x; } </script> </body> </html>