Home

KeyUp

In web development, keyup is a keyboard event that fires when the user releases a key after pressing it. It is a type of DOM event that can bubble up through the document tree and is typically listened for on elements with keyboard focus, such as input and textarea, or on the document.

Keyup follows keydown (and usually keypress, though keypress is deprecated) and represents the moment the key

The event handler receives a KeyboardEvent object. Useful properties include key, which contains the character or

Common uses include performing validation or finalizing input after the user finishes typing, or implementing lightweight

Cross-browser notes: modern browsers implement keyup consistently as part of the KeyboardEvent interface. For compatibility, prefer

is
released.
It
fires
for
most
keys,
including
letters,
digits,
and
control
keys
like
Enter
or
Escape.
If
multiple
keys
are
pressed
at
once,
each
key's
release
will
trigger
its
own
keyup
event
when
released.
action
(for
example
'a'
or
'Enter'),
and
code,
which
identifies
the
physical
key
(for
example
'KeyA'
or
'Enter').
Modern
code
generally
avoids
deprecated
keyCode
and
which
properties
in
favor
of
key
and
code.
The
event
also
exposes
modifier
flags
such
as
altKey,
ctrlKey,
shiftKey,
and
metaKey,
and
a
boolean
repeat
that
indicates
auto-repeated
keydowns.
search
suggestions.
Because
keyup
occurs
after
the
input
value
often
changes,
it
is
sometimes
used
in
tandem
with
the
input
event
to
avoid
reacting
to
every
keystroke.
e.key
and
e.code
and
fall
back
to
e.keyCode
only
if
necessary.
Attach
listeners
with
addEventListener('keyup',
handler)
on
the
appropriate
element
or
window.