Name
HTMLElement.onkeypress: event handler invoked when the user presses a key â DOM Level 0
Synopsis
Function onkeypress
Description
The onkeypress
property of
an HTMLElement object specifies an event-handler function that is
invoked when the user presses and releases a key while the element
has the keyboard focus. A keypress event is generated after a
keydown event and before the corresponding keyup event. The keypress
and keydown events are similar, although a keypress event is often
more useful for alphanumeric keys, and a keydown handler can be more
useful for function keys.
Determining which key was pressed and what modifier keys were in effect at the time is somewhat complex and browser-dependent. See Chapter 17 for details.
See Also
HTMLElement.onkeydown
;
Chapter 17
Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.