.keydown() is jQuery’s legacy shorthand for the keydown event (since 1.0). Pass a handler to bind; call it with no arguments to trigger. Binding forms are deprecated since jQuery 3.3.
Recognize the shorthand in old code, then migrate to .on / .trigger.
Find .keydown(fn) or bare .keydown() in legacy scripts.
Rewrite binds as .on("keydown", fn) (add eventData as the middle arg if needed).
Rewrite triggers as .trigger("keydown").
Keep using event.which for key codes — that part does not change.
Piece
Required?
Role
handler
For bind
function(event) { … }
eventData
Optional
Object → event.data (since 1.4.3)
No args
—
Trigger keydown on matched elements
Return
—
jQuery object (chainable)
Pseudocode
Pseudocode
if called with handler:
// deprecated since 3.3
bind handler to "keydown" on each element
(same as .on("keydown", handler))
if called with (eventData, handler):
bind with data → event.data
(same as .on("keydown", eventData, handler))
if called with no arguments:
fire "keydown" on each matched element
(same as .trigger("keydown"))
Reference
Cheat Sheet
Legacy vs modern — keep this table for quick migrations.
Legacy
Modern
$("#el").keydown(fn)
$("#el").on("keydown", fn)
$("#el").keydown(data, fn)
$("#el").on("keydown", data, fn)
$("#el").keydown()
$("#el").trigger("keydown")
Delegation
Only via .on("keydown", "input", fn)
Unbind
$("#el").off("keydown")
Status
Deprecated since jQuery 3.3
Try it
Live Preview
Compare the deprecated shorthand with the modern API. Press a key (hold to see repeat), or click Trigger to fire handlers.
Browser demo of .keydown() vs .on("keydown") — same event underneath.
Result
$("#field").keydown(fn) // deprecated bind
→ press a key to fire
/* prefer .on("keydown", fn) */
Code
jQuery Examples
Short demos of the legacy shorthand and how to migrate. Prefer .on / .trigger in new code.
Example 1 — Bind with .keydown(handler)
Legacy bind — runs when a key is pressed while the input has focus.
jQuery
$("#target").keydown(function () {
console.log("Handler for keydown called.");
});
Press "A" → Called 1 | key: 65
Press Enter → Called 2 | key: 13
(Enter default blocked)
How It Works
Same which codes as the modern keydown event API.
preventDefault on Enter (13) stops default form submit.
Count climbs on every press — including OS hold-repeat.
Swap the binder to .on("keydown", …) without changing the body.
Edge Cases & Pitfalls
Watch for these when reading or migrating .keydown().
deprecated
Do not use in new code
Binding with .keydown(fn) is deprecated since 3.3. Write .on("keydown", fn).
overload
Bind vs trigger look alike
.keydown(fn) binds; .keydown() triggers. Easy to confuse when skimming. Modern APIs make the intent obvious.
delegation
No selector form
.keydown() cannot delegate. Use $("#app").on("keydown", "input", fn) for dynamic fields.
event
Same keydown rules
Still needs focus; still may repeat while held. For release use keyup; for text values prefer the input event.
Compatibility
Browser Support
.keydown() has been available since jQuery 1.0 (eventData since 1.4.3) and is deprecated since jQuery 3.3. Prefer .on("keydown") / .trigger("keydown") everywhere jQuery runs.
✓ Deprecated · jQuery 3.3
jQuery .keydown()
Works in Chrome, Firefox, Safari, and Edge with jQuery 1.0+. Still present in jQuery 3.x for compatibility. New code should use .on('keydown') and .trigger('keydown').
LegacyPrefer .on / .trigger
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.keydown()Deprecated
Bottom line: Learn .keydown() to read legacy code. Write .on("keydown", fn) and .trigger("keydown") in new projects.
Analysis
Performance Notes
Approach
Cost
Best for
.keydown(fn) / .on("keydown", fn)
Same
Shorthand is a thin alias — no speed win
.on("keydown", "sel", fn)
One listener
Dynamic inputs (delegation)
Heavy work per press
Noticeable
Keep handlers light — hold-repeat can spam
Migrating to .on does not change performance — it clarifies intent and unlocks delegation. Optimize the handler body, not the binding API.
Remember
Key Takeaways
Role: legacy bind/trigger shorthand for the keydown event.
Status: binding forms deprecated since jQuery 3.3.
Migrate:.on("keydown", fn) and .trigger("keydown").
Event: same press/hold-repeat rules as the keydown event.
One line:.keydown() is the old name — learn it for legacy code, write .on("keydown") / .trigger("keydown") for new work.
Frequently Asked Questions
With a handler — .keydown(handler) or .keydown(eventData, handler) — it binds a function that runs when the user presses a key on a focused element. With no arguments — .keydown() — it triggers the keydown event and runs bound handlers. Binding forms are deprecated since jQuery 3.3.
Yes. Since jQuery 3.3, .keydown(handler) and .keydown(eventData, handler) are deprecated. Use .on("keydown", handler) instead. Prefer .trigger("keydown") over no-argument .keydown().
.keydown(fn) registers a callback and does not fire immediately. .keydown() with no arguments triggers keydown on each matched element — same idea as .trigger("keydown").
Replace .keydown(fn) with .on("keydown", fn). Replace .keydown(data, fn) with .on("keydown", data, fn). Replace bare .keydown() with .trigger("keydown"). Under the hood the shorthand already uses .on — migration is a rename.
Yes. jQuery 3.x keeps it for compatibility. It still binds and triggers. The docs mark it deprecated so new projects use .on() and .trigger(). See the keydown event tutorial for the modern API.
Yes. keydown can repeat at the OS key-repeat rate while held. .keydown(handler) follows the same rule. keyup fires once on release.