Output the actual key that was released inside a text field: - Javascript DOM Event

Javascript examples for DOM Event:onkeyup

Description

Output the actual key that was released inside a text field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

Enter your name: <input type="text" id="fname" onkeyup="myFunction()">

<p>My name is: <span id="demo"></span></p>

<script>
function myFunction() {/*ww  w .  j  a  v a  2s  . c o m*/
    var x = document.getElementById("fname").value;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials