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 keyCode Property</h2> <p>Press a keyboard key in the input field and display the value:</p> <input type="text" size="40" onkeypress="myFunction(event)"> <p id="demo"></p> <p>The keyCode property is deprecated, use the key property instead.</p> <script> function myFunction(event) { let value= event.which; document.getElementById("demo").innerHTML = value; } </script> </body> </html>