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>Keyboard Events</h1> <h2>The key Property</h2> <p>Press a key on the keyboard in the input field.</p> <input type="text" size="40" onkeydown="myFunction(event)"> <p id="demo"></p> <script> function myFunction(event) { let key = event.key; document.getElementById("demo").innerHTML = "The key was: " + key; } </script> </body> </html>