Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>HTML DOM Events</h1> <h2>The onkeydown Event</h2> <p>Assign an "onkeydown" event to an input element.</p> <p>Press a key in the input field:</p> <input type="text" onkeydown="myFunction(this)"> <script> function myFunction(element) { element.style.backgroundColor = "red"; } </script> </body> </html>