The keyup event fires when the user releases a key. It runs once per press-and-release — it does not repeat while held (unlike keydown). Bind with .on("keyup") since jQuery 1.7; the event reaches only the focused element.
Remember
$("#target").on("keyup", handler) // bind (1.7+)
$("#target").trigger("keyup") // fire handlers (1.0+)
event.which → key code (same idea as keydown)
Enter 13 · Esc 27 · Space 32 · arrows 37–40 · A–Z 65–90
keydown → may repeat while held
keyup → once when the key comes up
Focus a field, bind a handler, then react when the key comes up.
Pick a focusable target — usually an <input> or <textarea>.
Bind with $("#target").on("keyup", handler) (jQuery 1.7+).
Read event.which for the key code of the released key.
For page-wide shortcuts, bind on document (events bubble).
Piece
Required?
Role
Focused element
Yes
Only the focused element receives keyup
handler
Yes
function(event) { … }
eventData
Optional
Object passed as event.data
Return
—
jQuery object (chainable)
Pseudocode
Pseudocode
bind keyup on focused element
when user presses a key:
keydown may fire (and repeat while held)
when user releases the key:
keyup fires once
code = event.which // key code
react (validate, count, shortcut…)
.trigger("keyup") → run handlers without a real release
Reference
Cheat Sheet
Keep these facts handy while handling key release.
Focus #target, press and release a key →
Handler for keyup called.
(Fires on release — including arrows and Escape)
How It Works
Select the input.$("#target") must be able to receive focus.
Bind keyup..on("keyup", fn) registers the handler (jQuery 1.7+).
Release a key. After press-and-release, the handler runs once.
Any key works. Unlike keypress, arrows and Escape also fire keyup.
Example 2 — Trigger Keyup from a Button
Fire the bound handler programmatically with .trigger("keyup").
jQuery
$("#target").on("keyup", function () {
console.log("Handler for keyup called.");
});
$("#other").on("click", function () {
$("#target").trigger("keyup");
});
Hold "A" briefly → keydown may be 5+, keyup is 1
Quick tap → both near 1
Same which code on both events
How It Works
Two counters. keydown and keyup each track how often they fire.
Hold the key. keydown climbs with OS repeat; keyup stays put until release.
Release once. keyup increments by one for that press-and-release cycle.
Same which. Both events report the same key code for the physical key.
Edge Cases & Pitfalls
Check these before relying on keyup in real projects.
focus
Needs focus
keyup is delivered only to the focused element. Click the field first, or bind on document for page-wide shortcuts.
timing
Character already inserted
By the time keyup runs, the character is usually already in the field. That makes keyup handy for live length checks — or use the input event for paste too.
repeat
No hold-repeat
Holding a key does not spam keyup. If you need continuous updates while held, use keydown.
shorthand
Avoid .keyup(fn)
The .keyup() method is deprecated since 3.3. Prefer .on("keyup", fn) and .trigger("keyup").
Compatibility
Browser Support
jQuery’s .on("keyup") (since 1.7) and .trigger("keyup") (since 1.0) work wherever jQuery runs. Native keyup is widely supported. Prefer .on("keyup") over deprecated .keyup().
✓ jQuery 1.7+
jQuery keyup event
Works in Chrome, Firefox, Safari, and Edge with jQuery loaded. Use .on('keyup') for binding and .trigger('keyup') to fire handlers. The .keyup() shorthand is deprecated since 3.3.
ExcellentModern browser support
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
keyupExcellent
Bottom line: Safe for production with jQuery. Bind with .on('keyup'), not deprecated .keyup(). For text-value changes including paste, consider the input event.
Analysis
Performance Notes
Approach
Cost
Best for
.on("keyup", fn)
Once per release
Validation, counts, “done pressing”
.on("keydown", fn)
Per key + repeat
Shortcuts; held keys
input event
Per value change
Text fields (incl. paste)
keyup is lighter than keydown for held keys because it does not repeat. Still keep handlers small — debounce expensive search or network work.
Remember
Key Takeaways
Role: react when a key is released on the focused element.
API: bind with .on("keyup"); fire with .trigger("keyup").
Codes:event.which is the key code (same family as keydown).
Timing: once per release — use keydown when you need hold-repeat.
One line:keyup means “the key came up” — one fire per release, with event.which telling you which key.
Frequently Asked Questions
keyup fires when the user releases a key. Unlike keydown, it does not repeat while a key is held — one keyup per press-and-release. Bind with .on('keyup', handler) since jQuery 1.7. The event reaches only the focused element.
keydown fires when a key goes down and repeats while held (OS key repeat). keyup fires once when the key comes back up. Both use the same event.which key codes. Prefer keydown for shortcuts and movement; prefer keyup when you react after the press finishes.
Use event.which — jQuery normalizes it across browsers. Common codes: 13 Enter, 27 Escape, 32 Space, 37–40 arrows, 65–90 letters A–Z. The code is which key was released.
Call $('#target').trigger('keyup') since jQuery 1.0. Bound handlers run. .trigger() does not simulate a full physical press and release — it runs jQuery-bound handlers once per call.
Use keyup for validation after typing, live character counts, detecting when a modifier is released, or logic that should run once per keystroke after the character appears. Use keydown for immediate shortcuts, games, and held-key repeat.
The element must have focus when the key is released. Click inside an input first, or set tabindex on custom widgets. For page-wide shortcuts, bind on document.