Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>Keyboard Events</h1>
<h2>The which 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 which property is deprecated, use the key property instead.</p>
<script>
function myFunction(event) {
  let value = event.which;
  document.getElementById("demo").innerHTML = "The value is: " + value;
}
</script>
</body>
</html>