Name
KeyEvent: details about a keyboard event — Firefox and compatible browsers: Event → UIEvent → KeyEvent
Properties
-
readonly boolean altKey Whether the Alt key was held down when the event occurred.
-
readonly integer charCode This number is the Unicode encoding of the printable character (if any) generated by a keypress event. This property is zero for nonprinting function keys and is not used for keydown and keyup events. Use
String.fromCharCode( )to convert this property to a string.-
readonly boolean ctrlKey Whether the Ctrl key was held down when the event occurred. Defined for all types of mouse events.
-
readonly integer keyCode The virtual keycode of the key that was pressed. This property is used for all types of keyboard events. Keycodes may be browser-, OS-, and keyboard-hardware-dependent. Typically, when a key displays a printing character on it, the virtual keycode for that key is the same as the encoding of the character. Key codes for nonprinting function keys may vary more, but see Example 17-6 for a set of commonly used codes.
-
readonly boolean shiftKey Whether the Shift key was held down when the event occurred. Defined for all types of mouse events.
Description
A KeyEvent object provides details about a keyboard event and is passed to event handlers for keydown, keypress, and keyup events. The DOM Level 2 Events standard does not cover keyboard events, and the KeyEvent object has not been standardized. This entry describes the Firefox implementation. Many of these ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access