KeyboardEvent shiftKey Property
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:
|
---|---|
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