HTML onkeyup Event Attribute

❮ HTML Event Attributes

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 attribute fires 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 Attribute
onkeyup Yes Yes Yes Yes Yes

Syntax

<element onkeyup="script">

Attribute Values

Value Description
script The script to be run on onkeyup

Technical Details

Supported HTML tags: All HTML elements, EXCEPT: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title>

More Examples

Example

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

<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() {
  let x = document.getElementById("fname").value;
  document.getElementById("demo").innerHTML = x;
}
</script>
Try it Yourself »

Related Pages

HTML DOM reference: onkeyup event


❮ HTML Event Attributes
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.