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 charCode 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 charCode property is deprecated. Use the key property instead.</p> <script> function myFunction(event) { let value = event.charCode; document.getElementById("demo").innerHTML = "The value is: " + value; } </script> </body> </html>