The MouseEvent.shiftKey read-only property indicates if the shift key was pressed (true) or not (false) when the event occurred.

Syntax

var shiftKeyPressed = instanceOfMouseEvent.shiftKey

Return value

A boolean

Example

<html>
<head>
<title>shiftKey example</title>

<script type="text/javascript">
document.addEventListener('click', function(e) {
  console.log('Is Shift key pressed?', e.shiftKey);
})
</script>
</head>

<body>
<p>
Click anywhere on the page and open your developer console to see the results.
</p>
</body>
</html>

Specifications

Specification Status Comment
Document Object Model (DOM) Level 3 Events Specification
The definition of 'MouseEvent.shiftKey' in that specification.
Obsolete No change from Document Object Model (DOM) Level 2 Events Specification.
Document Object Model (DOM) Level 2 Events Specification
The definition of 'MouseEvent.shiftKey' in that specification.
Obsolete Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android ? Chrome Android ? Edge Mobile Full support YesFirefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

See also

Document Tags and Contributors

Contributors to this page: janzenz, fscholz, libbymc, teoli, kscarfone, amycb, Jeremie
Last updated by: janzenz,