HTML onkeyup Attribute

HTML onkeyup Attribute: The HTML onkeyup attribute is defined as it fires when the user releases a key. This attribute contains a single value script which works when the keyboard key is released. And the order of events related to the onkeyup event:

  • onkeydown
  • onkeypress
  • onkeyup

HTML onkeyup Attribute

This attribute can be applied to all the HTML elements.

Supported Tags: It is supported by all HTML elements except <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title>.



Syntax: <element onkeyup = “script”>

Browser Support

This attribute is supported by the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Opera
  • Internet Explorer

Example: for the input element

<!DOCTYPE html>
<html>
<body>
<p>A function is triggered when the user releases a key and it transforms the character to upper case.</p>
Enter your name: <input type="text" id="fname" onkeyup="myFunction()">
<script>
function myFunction() {
  var x = document.getElementById("fname");
  x.value = x.value.toUpperCase();
}
</script>

</body>
</html>

Output:

HTML onkeyup attribute