Javascript examples for DOM:Key Event
KeyEvent keyCode Property - Check if the user presses the Escape key:
<!DOCTYPE html> <html> <body> <input type="text" size="50" onkeydown="keyCode(event)"> <script> function keyCode(event) {// www.j a va2s .co m var x = event.keyCode; if (x == 27) { console.log("You pressed the Escape key!"); } } </script> </body> </html>