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