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

Javascript examples for DOM Event:onkeyup

Description

Using "onkeyup" together with the "onkeydown" 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() {//www . j  a va2  s .co  m
    document.getElementById("demo").style.backgroundColor = "red";
}

function keyupFunction() {
    document.getElementById("demo").style.backgroundColor = "green";
}
</script>

</body>
</html>

Related Tutorials