Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery keyup() method

jQuery keyup() method

jQuery event methods jQuery event methods

Example

When a keyboard key is released, set the field's background color:

$

(

"

input

"

)

.

keyup

(

function

(

)

{

$

(

"

input

"

)

.

css

(

"

background-color

"

,

"

pink

"

)

;

}

)

;

Try it »


Definition and Usage

Event sequence related to the keyup event:

  1. keydown - the process of a key being pressed
  2. keypress - the key is pressed
  3. keyup - the key is released

The keyup event occurs when a keyboard key is released.

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

**Tip:** Please use event.which property to return which key was pressed.


Syntax

Trigger the keyup event of the selected element:

$(

selector

).keyup()

Try it

Add a function to the keyup event:

$(

selector

).keyup(

function

)

Try it

Parameters Description
function Optional. Specifies the function to run when the keyup event is triggered.

More examples

Determine which key was pressed
How to use the event.which property to determine which key was pressed.


jQuery event methods jQuery event methods