The keyup event fires when a key is released. Learn addEventListener vs onkeyup, key vs code, pairing with keydown, Tab focus caveats, IME tips, and five try-it labs.
01
Kind
Instance event
02
Type
KeyboardEvent
03
When
Key released
04
Handler
onkeyup
05
Pair
keydown
06
Status
Baseline widely available
Fundamentals
Introduction
If keydown is “the key went down,” keyup is “the key came back up.” That release signal is perfect for stopping movement, ending a hold-to-fire action, or committing a shortcut only after the key lifts.
The event target is usually the focused element. If nothing suitable is focused, it may be Document or the root. The event bubbles to Document and Window.
💡
Beginner tip
For held keys, start on keydown and stop on keyup. For one-shot shortcuts (Save, Escape), keydown alone is often enough.
Concept
Understanding keyup
An instance event that answers: “Did a key just get released?”
A KeyboardEvent (inherits from UIEvent and Event).
Handy properties
Property
Meaning
key
Key value (e.g. "a", "Enter", "Escape")
code
Physical key id (e.g. "KeyA", "ArrowUp")
ctrlKey / shiftKey / altKey / metaKey
Modifier flags active during the event
isComposing
true during IME composition (between compositionstart/end)
Compare
⚖️ keyup vs keydown vs keypress
Topic
keyup
keydown
keypress
When
Key is released
Key goes down (may repeat)
Character keys (legacy)
All keys?
Yes
Yes
No — mainly printable
Status
Modern / Baseline
Modern / Baseline
Deprecated
Best for
Stop / release / commit
Start / shortcuts / games
Avoid in new code
Caveat
⚠️ Tab Can Change the Target Before keyup
MDN notes that the event target can differ between keydown and keyup. With Tab, focus moves on the way down, so the release may fire on the newly focused element.
For IME composition, skip keyup when event.isComposing is true. Unlike keydown, there is no special keyCode === 229 marker on keyup.
keyup is marked Baseline Widely available on MDN. Logos use the shared browser-image-sprite.png sprite from this project. KeyboardEvent key/code are the modern path across engines.
✓ Baseline · Widely available
Element keyup
Fires when a key is released; pair with keydown for press/release control.
FullWidely available
Google ChromeFull support
Yes
Mozilla FirefoxFull support
Yes
Apple SafariFull support
Yes
Microsoft EdgeFull support
Yes
OperaFull support
Yes
Internet ExplorerSupported (prefer feature-detect modern key/code)
Partial
keyupBaseline
Bottom line: Safe default for release handling. Watch Tab target changes and skip IME composition keyups.
Wrap Up
Conclusion
keyup completes the keyboard story: detect the release, clean up held state, and pair it with keydown for full press/release control.
Account for Tab changing the focused target before release
Prefer addEventListener in production code
❌ Don’t
Rely on deprecated keypress for release logic
Assume keydown and keyup always share the same target
Forget to clear held-key sets when the window loses focus
Ignore IME composition in international text apps
Overwrite onkeyup if you need multiple listeners
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about keyup
Key released—stop holds and finish the keyboard pair.
5
Core concepts
📱01
Key released
end of the press
Trigger
📄02
KeyboardEvent
key · code · mods
API
⚡03
Pairs with keydown
start / stop
Pattern
🔄04
Tab caveat
target may change
Focus
🎯05
Baseline
widely available
Status
❓ Frequently Asked Questions
It fires when a key is released. Together with keydown it gives you a press/release pair for shortcuts, games, and held-key controls.
No. MDN marks Element keyup as Baseline Widely available. It is not Deprecated, Experimental, or Non-standard.
A KeyboardEvent (inherits from UIEvent and Event). Useful properties include key, code, altKey, ctrlKey, shiftKey, metaKey, and isComposing.
keydown fires when the key goes down (and may repeat while held). keyup fires once when the key is released. Start actions on keydown; stop or commit on keyup.
Yes. For Tab, keydown and keyup can target different elements because focus already moved. Always check event.target when that matters.
Skip events when event.isComposing is true. Unlike keydown, keyup does not use the special keyCode 229 IME marker.
Did you know?
If the user Alt-Tabs away while holding a key, you may miss keyup. Many games also clear held-key state on blur / visibilitychange so movement does not stick.