jQuery Keyboard Events

About This Index
This page is the jQuery Keyboard Events index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.
Learn the jQuery overview on /jquery. Use this page when you need a keyboard event such as keydown, keypress, or keyup.
Start with keydown, then keyup—use keypress only for printable characters. Prefer .on() over the legacy shorthands.
How to Call a Keyboard Event
Bind with .on() and read event.which (and modifiers) in the handler:
$("#q").on("keydown", function (event) {
if (event.which === 13) { // Enter
console.log("submit search");
}
});
$(document).on("keydown", function (event) {
if (event.ctrlKey && event.which === 83) {
event.preventDefault(); // Ctrl+S shortcut
}
});
$("#q").on("keyup", function () {
console.log($(this).val());
});
$("#q").trigger("keydown"); jQuery Keyboard Events Table
All Keyboard Events guides in this jQuery tutorial series (6 tutorials).
Key Down
2 methodsReact when a key is pressed — best for shortcuts, arrows, and Escape.
| Method | Description | Tutorial |
|---|---|---|
keydown | Bind or trigger when a key is pressed — repeats while held; read event.which for the key code. | Try it |
.keydown() | Deprecated shorthand — prefer .on('keydown') and .trigger('keydown') (since 3.3). | Try it |
Key Press
2 methodsReact to printable character input — less useful for modifier-only keys.
| Method | Description | Tutorial |
|---|---|---|
keypress | Bind or trigger for printable character input — event.which holds the character code. | Try it |
.keypress() | Deprecated shorthand — prefer .on('keypress') and .trigger('keypress') (since 3.3). | Try it |
Key Up
2 methodsReact when a key is released — finish actions started on keydown.
Frequently Asked Questions
Start with keydown
Open the keydown guide—syntax, examples, and FAQs.
16 people found this page helpful
