Keyup event in JavaScript

We will use Keyup event to execute one or more JavaScript function when a user press a key.
The "Keyup" event will be fired after the "keydown" and "keypress" events.

Example:

In the below example when we pass the "event" as parameter to the function, the keyup event will passed as a parameter and when we pass "this" as parameter, then the event calling control will be passed as parameter.

Enter Value :






Code Sample:

<html> <head> <title>keyup event example in JavaScript</title> <script language="Javascript"> var res = ""; function keydown1(evt, t) { res = res + "keydown- keycode:" + evt.keyCode + ", value:" + t.value + "<br/>"; document.getElementById("tdresult").innerHTML = res; } function keypress1(evt, t) { if (window.event) res = res + "keypress- keycode:" + evt.keyCode + ", value:" + t.value + "<br/>"; else res = res + "keypress- keycode:" + evt.charCode + ", value:" + t.value + "<br/>"; document.getElementById("tdresult").innerHTML = res; } function keyup1(evt, t) { res = res + "keyup- keycode:" + evt.keyCode + ", value:" + t.value + "<br/>"; document.getElementById("tdresult").innerHTML = res; res = ""; } </script> </head> <body> <table align="left"> <tr> <td> Enter Value : <input type="text" id="Text1" onkeydown="keydown1(event,this);" onkeyup="keyup1(event,this);" onkeypress="keypress1(event,this);" style="width: 200px;" /> </td> </tr> <tr> <td id="tdresult"></td> </tr> </table> </body> </html>