Using "onkeydown" together with the "onkeyup" event: - Javascript DOM Event

Javascript examples for DOM Event:onkeydown

Description

Using "onkeydown" together with the "onkeyup" event:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials