<html>
<body>
<h1>HTML DOM Events</h1>
<h2>The onkeydown Event</h2>
<p>Use the addEventListener() method to attach a "keydown" event to an input element.</p>
<p>Press a key inside the text field to set a red background color.</p>
<input type="text" id="demo">
<script>
document.getElementById("demo").addEventListener("keydown", myFunction);
function myFunction() {
document.getElementById("demo").style.backgroundColor = "red";
}
</script>
</body>
</html>