--- title: MouseEvent.getModifierState() slug: Web/API/MouseEvent/getModifierState translation_of: Web/API/MouseEvent/getModifierState ---

{{APIRef("DOM Events")}}

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 {{domxref("KeyboardEvent.getModifierState","KeyboardEvent.getModifierState()")}} for details.

语法

var active =​ event.getModifierState(keyArg);

返回值

A {{jsxref("Boolean")}}

参数

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

规范

Specification Status Comment
{{SpecName('DOM3 Events', '#widl-MouseEvent-getModifierState', 'getModifierState()')}} {{Spec2('DOM3 Events')}} Initial definition.

浏览器兼容性

{{Compat("api.MouseEvent.getModifierState")}}

See also