The onkeyup attribute is an inline event handler for the keyup event. It runs when the user releases a key on a focused element — for example an <input>, <textarea>, or any focusable control (see tabindex).
Unlike deprecated onkeypress, keyup fires for Escape, arrows, and most other keys. Compare with onkeydown (press) and oninput (value changed).
Baseline · Widely available.
Not deprecated and not experimental. Stable across modern browsers since about July 2015.
Syntax
HTML Syntax
syntax.html
<element onkeyup="script">
script is JavaScript that runs when the key is released. Pass event to read event.key or event.code. Script alternative: element.addEventListener("keyup", handler).
Compare e.key. Named keys use strings like "Escape" and "Enter".
Act on release. Clearing after keyup avoids fighting the browser while the key is down.
Use e.target. The focused input that received the event.
Give feedback. A short message helps users know Escape did something.
Edge Cases & Pitfalls
Most surprises come from timing: focus changes and when the character appears in the field.
timing
Value is already updated
On keyup for a character key, the input usually already contains the new character — good for reading value.
focus
Tab can change the target
MDN notes that keydown and keyup targets can differ when focus moves (for example Tab). Do not assume they match.
modifiers
Modifier flags after release
On the keyup for Control itself, ctrlKey is false. Flags reflect state after that key is released.
IME
Composition (CJK input)
During IME composition, skip handling when event.isComposing is true so unfinished characters are not treated as final input.
paste
Paste does not fire keyup per character
For value-based filters that must catch paste, use oninput (optionally with keyup).
Compatibility
Browser Support
onkeyup is an HTML event handler for the keyup event in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
onkeyup
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support keyup well on desktop and mobile.
98%Global support (approx.)
Google ChromeAll modern
Full support
Mozilla FirefoxAll modern
Full support
Apple SafariAll modern
Full support
Microsoft EdgeAll modern
Full support
OperaAll modern
Full support
Samsung InternetModern
Full support
Internet Explorer9+
Supported
onkeyupWidely supported
Bottom line: Safe to use for keyboard release handling. Prefer addEventListener('keyup') in larger apps; inline onkeyup is fine for learning.
Remember
Key Takeaways
Role: run script when a key is released on a focused element.
vs keydown: keydown is press (can repeat); keyup is release (once).
vs input: use oninput when you care about value changes including paste.
API: use event.key / event.code, not keyCode.
One line:onkeyup handles the release — pair with onkeydown for press and oninput for value.
Frequently Asked Questions
It is an inline event handler that runs JavaScript when the keyup event fires — when the user releases a key while the element is focused (or on document/window via script).
onkeydown fires when the key goes down (and may repeat while held). onkeyup fires once when the key is released. Use keydown for shortcuts that should feel immediate; keyup when you want the action after release.
oninput fires whenever the value changes (typing, paste, autofill). Prefer oninput for filtering field text. Use onkeyup when you specifically care that a physical key was released (for example Escape or Enter).
Yes. Unlike the deprecated keypress event, keyup fires for Escape, arrows, and most other keys.
Use event.key (and event.code for the physical key). keyCode and which are deprecated.
Yes. It is Baseline widely available (since about July 2015) across modern desktop and mobile browsers.