Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <script> function myFunction() { alert("You pressed a key inside the input field"); } </script> </head> <body> <h1>JavaScript HTML Events</h1> <h2>The onkeydown Attribute</h2> <p>A function is triggered when the user is pressing a key in the input field.</p> <input type="text" onkeydown="myFunction()"> </body> </html>