X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

onkeyup Event

Event Object Reference Event Object

Example

Execute a JavaScript when a user releases a key:

<input type="text" onkeyup="myFunction()">

Try it yourself »

More "Try it Yourself" examples below.


Definition and Usage

The onkeyup event occurs when the user releases a key (on the keyboard).

Tip: The order of events related to the onkeyup event:

  1. onkeydown
  2. onkeypress
  3. onkeyup

Browser Support

Event
onkeyup Yes Yes Yes Yes Yes


Syntax

In HTML:

<element onkeyup="myScript">Try it

In JavaScript:

object.onkeyup=function(){myScript};Try it

In JavaScript, using the addEventListener() method:

object.addEventListener("keyup", myScript);Try it

Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.


Technical Details

Bubbles: Yes
Cancelable: Yes
Event type: KeyboardEvent
Supported HTML tags: All HTML elements, EXCEPT: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title>


Examples

More Examples

Example

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

<input type="text" onkeydown="keydownFunction()" onkeyup="keyupFunction()">

Try it yourself »

Example

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

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

<script>
function myFunction() {
    var x = document.getElementById("fname").value;
    document.getElementById("demo").innerHTML = x;
}
</script>

Try it yourself »


Event Object Reference Event Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook