Section 25.193. KeyEvent: details about a keyboard event


25.193. KeyEvent: details about a keyboard event

Firefox and compatible browsers: Event UIEvent KeyEvent

25.193.1. 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.

25.193.2. 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 properties are also supported in the IE event model; see the IE-specific properties described for the Event object. Note that in addition to the properties listed here, KeyEvent objects also inherit the properties of Event and UIEvent.

Chapter 17 includes several practical examples of working with KeyEvent objects.

25.193.3. See Also

Event, UIEvent; Chapter 17




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net