Javascript examples for DOM Event:onkeydown
Using "onkeydown" together with the "onkeyup" event:
<!DOCTYPE html> <html> <body> <input type="text" id="demo" onkeydown="keydownFunction()" onkeyup="keyupFunction()"> <script> function keydownFunction() {//from w ww . ja va 2 s. co m document.getElementById("demo").style.backgroundColor = "red"; } function keyupFunction() { document.getElementById("demo").style.backgroundColor = "green"; } </script> </body> </html>