jQuery keyup() method
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:
- keydown - the process of a key being pressed
- keypress - the key is pressed
- 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