jQuery Event - keyup() Method

Example

Change the text field color when a key is pressed:

$("input").keyup(function(){
  $("input").css("background-color","#D6D6FF");
});

Try it yourself

Definition and usage

The complete key press process is divided into two parts: the key is pressed, and then the key is released and reset.

The keyup event occurs when a button is released. It occurs on the element currently in focus.

The keyup() method triggers the keyup event, or specifies the function to be executed when a keyup event occurs.

Note:If set on a document element, the event will occur regardless of whether the element is focused or not.

Tip:Please use .which propertyTo determine which key is pressed (Try it yourself)。

Trigger the keyup event

Syntax

$(selector).keyup()

Try it yourself

Bind the function to the keyup event

Syntax

$(selector).keyup(function)
Parameters Description
function Optional. Specifies the function to be executed when a keyup event occurs.

Try it yourself