Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>Keyboard Events</h1>
<h2>The key Property</h2>
<p>Press the "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;
  if (key == "a" || key == "A") { 
    let text = "You pressed the 'A' key!";
    document.getElementById("demo").innerHTML = text;
  }
}
</script>
</body>
</html>