Home

Keypress

Keypress describes an input event triggered when a user presses a key on a keyboard. In many user interface frameworks, the keypress event specifically represents the character produced by the key press, whereas other events such as keydown and keyup reflect the physical act of pressing and releasing keys. Because of differences among platforms and libraries, the precise meaning of keypress can vary.

In practice, keypress data typically includes information about the character generated by the key and modifiers

In web browsers, there are three related events: keydown, keypress, and keyup. Keydown fires when any key

Keypress events are commonly used for implementing keyboard shortcuts, text entry, and game controls. They may

See also: keyboard event, input event, Unicode, key code.

such
as
Shift
or
Ctrl.
Some
APIs
distinguish
between
printing
(character)
keys
and
non-printing
keys
like
Escape
or
Arrow
keys,
which
may
not
emit
a
character
value.
is
pressed;
keypress
is
intended
for
keys
that
produce
a
character;
keyup
fires
when
the
key
is
released.
Modern
web
standards
de-emphasize
keypress
and
may
not
fire
it
for
all
keys;
for
character
input,
it
is
often
safer
to
handle
keydown
with
character
translation
or
to
use
input
events
on
text
controls.
repeat
when
a
key
is
held
down,
depending
on
the
platform,
and
developers
must
consider
accessibility
and
internationalization
when
interpreting
key
input.