Name

HTMLElement.onkeydown: event handler invoked when the user presses a key — DOM Level 0

Synopsis

Function onkeydown

Description

The onkeydown property of an HTMLElement object specifies an event-handler function that is invoked when the user presses a key while the element has keyboard focus. Determing which key or keys were pressed is somewhat browser-dependent. See Chapter 17 for details.

The onkeydown handler is usually the prefered handler for function keys, but use onkeypress to respond to regular alphanumeric key presses.

See Also

HTMLElement.onkeypress; 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.