Tryit Editor v1.4

<html> <head> <script type="text/javascript"> function message() { alert("This alert box was triggered when you pressed a button on your keyboard"); } </script> </head> <body onkeypress="message()"> <p>The onkeypress event is triggered when the user presses a button on the keyboard.</p> <p>To trigger the onkeypress event, make sure that this window has focus.</p> </body> </html> | Your Result:
Edit the code above and click to see the result. | W3Schools.com - Try it yourself