jQuery keyup() Method

jQuery keyup() Method

The jQuery keyup() method is used for the following 2 purpose

  1. To run a callback when a keyboard key is released in a specified element.
  2. To trigger the keyup event of a specified element.

Run a Callback

In the following example, we will run a callback function when a keyboard key is released in any input.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery keyup() Method</h1> <input type="text" placeholder="type something"> <script> $(document).ready(function(){ $("input").keyup(function(){ alert("Key is up"); }); }); </script> </body> </html>

Syntax

$(selector).keyup(callback);

Parameter Values

ValueTypeExplanation
callbackOptionalSpecifies a function to be called once the key is up.

Trigger a keyup Event

In the following example, we will trigger a keyup event when a button is clicked.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery keyup() Method</h1> <input type="text" placeholder="type something"> <button>Trigger keyup Event</button> <script> $(document).ready(function(){ $("input").keyup(function(){ alert("Key is up"); }); $("button").click(function(){ $("input").keyup(); }); }); </script> </body> </html>

keydown() vs keypress() vs keyup()

Check out the difference between keydown() vs keypress() vs keyup() in jquery.

Reminder

Hi Developers, we almost covered 99.5% of jQuery Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in jQuery.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author