Skip to content
Related Articles

Related Articles

Improve Article

HTML | onkeyup Event Attribute

  • Difficulty Level : Basic
  • Last Updated : 06 Feb, 2019

This onkeyup event attribute works when the user releases the key from the keyboard.


<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>.


<!DOCTYPE html>
        <title>onkeyup Event Attribute </title>
            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;
        <h2>onkeyup Event Attribute</h2>
        <p>Release the key to set a green background color.</p>
        <input type="text" id="demo" onkeydown="keydownFunction()"
            function keydownFunction() {
                document.getElementById("demo").style.backgroundColor = "blue";
            function keyupFunction() {
                document.getElementById("demo").style.backgroundColor = "green";

Press the key:
Release the key:

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

  • Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :