MouseEvent shiftKey Property

Definition and Usage

The shiftKey property returns a boolean value indicating whether the "SHIFT" key was pressed when the mouse event was triggered.

Note:This property is read-only.

Example

Check if the "SHIFT" key was pressed when clicking the mouse button:

if (event.shiftKey) {
  alert("The SHIFT key was pressed!");
}
  alert("The SHIFT key was NOT pressed!");
}

Try It Yourself

Syntax

event.shiftKey

Technical Details

Return value:

A boolean value indicating whether the "SHIFT" key was pressed when the mouse event occurred.

Possible values:

  • true - Shift key pressed
  • false - Shift key not pressed
DOM Version: DOM Level 2 Events

Browser Support

Properties Chrome IE Firefox Safari Opera
shiftKey Support Support Support Support Support

Related Pages

HTML DOM Reference Manual:MouseEvent altKey Property

HTML DOM Reference Manual:MouseEvent ctrlKey Property

HTML DOM Reference Manual:MouseEvent metaKey Property