jQuery Keyboard Events

Beginner
6 min read
Updated: Nov 2026
6 method guides
Method index

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.

Beginner path.

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:

jQuery
$("#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 methods

React when a key is pressed — best for shortcuts, arrows, and Escape.

MethodDescriptionTutorial
keydownBind 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 methods

React to printable character input — less useful for modifier-only keys.

MethodDescriptionTutorial
keypressBind 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 methods

React when a key is released — finish actions started on keydown.

MethodDescriptionTutorial
keyupBind or trigger when a key is released — pair with keydown for hold detection.Try it
.keyup()Deprecated shorthand — prefer .on('keyup') and .trigger('keyup') (since 3.3).Try it

Frequently Asked Questions

They respond when keys are pressed or released: keydown when a key goes down, keyup when it comes up, and keypress for printable character input. Bind with .on() and read event.which for the key code.
Prefer .on('keydown', handler) and .trigger('keydown'). The .keydown(), .keypress(), and .keyup() shorthands are deprecated since jQuery 3.3.
keydown fires for almost every key (arrows, Escape, modifiers) and repeats while held. keypress is mainly for printable characters. Prefer keydown for shortcuts and game controls.
Bind on document: $(document).on('keydown', fn). The focused element receives the event first; it bubbles unless stopped. Filter with event.which and modifier flags like event.ctrlKey.
Start with keydown, then keyup. Use keypress only when you specifically need character input. Prefer .on() over the legacy shorthands.

Start with keydown

Open the keydown guide—syntax, examples, and FAQs.

keydown tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

16 people found this page helpful