<html>
<body>
<p>This example demonstrates how to assign an "onkeydown" 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" onkeydown="myFunction()">
<script>
function myFunction() {
document.getElementById("demo").style.backgroundColor = "red";
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onkeydown_html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 05 Jun 2019 14:04:37 GMT -->
</html>