KeyboardEvent shiftKey Property

Example

Was the shift key pressed when the event occurred?

if (event.shiftKey) {
  text = "The SHIFT key was pressed!";
} else {
  text = "The SHIFT key was NOT pressed!";
}
Try it Yourself »

Description

The shiftKey property returns true if the shift key is pressed when a mouse event is triggered, otherwise it returns false.

The altKey property is read-only.


Syntax

event.shiftKey

Technical Details

Return Value: A Boolean.
true if the shift key was pressed when a mouse event occured, otherwise false.
DOM Version: DOM Level 2 Keyboard Events.

Browser Support

event.shiftKey is a DOM Level 2 (2001) feature.

It is fully supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes 9-11


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.