Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

HTML | onkeyup Event Attribute

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

This onkeyup event attribute works when the user releases the key from the keyboard.
Supported Tags:  It supports all HTML elements Except- 

  • <base>
  •  <bdo>
  • <br>
  • <head>
  • <html>
  • <iframe>
  • <meta>
  • <param>
  • <script>
  • <style> 
  • <title>

Syntax: 
 

<element onkeyup = "script">

Attribute Value: This attribute contains single value script which works when the keyboard key is released. 
Supported Tags: It is supported by all HTML elements except <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title>.
Example: 
 

html




<!DOCTYPE html>
<html>
    <head>
        <title>onkeyup Event Attribute </title>
        <style>
            h1 {
                text-align: center;
                color: green;
            }
            h2 {
                text-align: center;
            }
            input[type=text] {
                width: 100%;
                padding: 12px 20px;
                margin: 8px 0;
                box-sizing: border-box;
                font-size: 24px;
                color: white;
            }
            p {
                font-size: 20px;
            }
        </style>
    </head>
    <body>
        <h1>GeeksforGeeks<h1>
        <h2>onkeyup Event Attribute</h2>
         
 
<p>Release the key to set a green background color.</p>
 
 
        <input type="text" id="demo" onkeydown="keydownFunction()"
                onkeyup="keyupFunction()">
        <script>
            function keydownFunction() {
                document.getElementById("demo").style.backgroundColor = "blue";
            }
 
            function keyupFunction() {
                document.getElementById("demo").style.backgroundColor = "green";
            }
        </script>
    </body>
</html>                   

Output: 
Press the key: 
 

onkeyup

Release the key: 
 

onkeyup

Supported Browser: The browser supported by onkeyup event attribute are listed below: 
 

  • Chrome 1
  • Edge 12
  • Internet Explorer 9
  • Firefox 6
  • Safari 1.2
  • Opera 12.1

 


My Personal Notes arrow_drop_up
Last Updated : 16 Aug, 2022
Like Article
Save Article
Similar Reads
Related Tutorials