THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

KeyboardEvent shiftKey Property

Event Object Reference Event Object

Example

Find out whether or not the "SHIFT" key was pressed when a keyboard key is pressed:

var x = document.getElementById("demo");
if (event.shiftKey) {
    x.innerHTML = "The SHIFT key was pressed!";
} else {
    x.innerHTML = "The SHIFT key was NOT pressed!";
}
Try it yourself »

Definition and Usage

The shiftKey property returns a Boolean value that indicates whether or not the "SHIFT" key was pressed when a key event was triggered.

Note: This property is read-only.


Browser Support

Property
shiftKey Yes Yes Yes Yes Yes

Syntax

event.shiftKey

Technical Details

Return Value: A Boolean, indicating whether the "SHIFT" key was pressed when the key event occured.

Possible values:

  • true - The shift key was pressed
  • false - The shift key was not pressed
DOM Version: DOM Level 2 Events

Related Pages

HTML DOM reference: KeyboardEvent altKey Property

HTML DOM reference: KeyboardEvent ctrlKey Property

HTML DOM reference: KeyboardEvent metaKey Property


Event Object Reference Event Object