English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery keyup() method

jQuery Events

The keyup() method triggers the keyup event, or attach a function to run when the keyup event occurs.

The keyup event occurs when the user releases a key.

Note:The event sequence related to the keyup event is:

Usingevent.whichThe attribute returns the key pressed on the keyboard.

Syntax:

Trigger the keyup event of the selected element:

$(selector).keyup()

Attach a function to the keyup event:

$(selector).keyup(function)

Example

An alert will pop up when the user releases the key:

$("input").keyup(function(){
  alert("Welcome to the Basic Tutorial www.oldtoolbag.com!!!");
});
Test and see‹/›

Set the background color of the <input> field when the keyboard key is released:

$("input").keyup(function(event){
  $("background-color", "lightblue");
  $("span").text(event.type);
});
Test and see‹/›

Determine which key was pressed:

$("input").keyup(function(event){ 
  $("div").text("Key:  " + event.which);
});
Test and see‹/›

Trigger the keyup event of the <input> field:

$("#btn2").click(function(){
  $("input").keyup();
});
Test and see‹/›

Parameter Value

ParameterDescription
functionFunction executed when a key event is triggered

jQuery Events