Javascript examples for DOM:Key Event
KeyEvent key Property - Check if the user presses the "A" key:
<!DOCTYPE html> <html> <body> <input type="text" size="40" onkeydown="myFunction(event)"> <script> function myFunction(event) {/*from w w w. j a v a 2 s . c o m*/ var x = event.key; if (x == "a" || x == "A") { console.log("You pressed the 'A' key!"); } } </script> </body> </html>