event.modifiers

JavaScript 1.2+ Nav4+ Syntax

							event.modifiers

Description

The modifiers property of the Event object refers to any keyboard modifier that occurs during an event. Modifiers are in the form of a bitmask object and may consist of the following values: ALT_MASK, CONTROL_MASK, META_MASK, and SHIFT_MASK.

Example

Listing 7.207 shows how the modifiers property can be accessed when some sort of modifier, such as a mouse or keyboard event, has occurred. The KEYPRESS event is captured and the modifiers property checked to see which type of key was pressed. If a match is found, a message is sent to the user so indicating.

Listing 7.207 Accessing the modifiers Property
 <html> <head> <title>Using the modifiers property for the event ...

Get Pure JavaScript 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.