MouseEvent.getModifierState()

The MouseEvent.getModifierState() method returns the current state of the specified modifier key: true if the modifier is active (i.e., the modifier key is pressed or locked), otherwise, false.

See the document of KeyboardEvent.getModifierState() for details.

语法

var active =​ event.getModifierState(keyArg);

返回值

A Boolean

参数

keyArg
A modifier key value. The value must be one of the KeyboardEvent.key values which represent modifier keys or "Accel". This is case-sensitive.

规范

Specification Status Comment
Document Object Model (DOM) Level 3 Events Specification
getModifierState()
Obsolete Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
getModifierStateChrome Full support 47Edge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari ? WebView Android Full support 47Chrome Android Full support 47Firefox Android Full support YesOpera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
"Accel" parameter
DeprecatedNon-standard
Chrome No support NoEdge ? Firefox ? IE ? Opera ? Safari ? WebView Android No support NoChrome Android No support NoFirefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.

See also