--- title: MouseEvent.getModifierState() slug: Web/API/MouseEvent/getModifierState translation_of: Web/API/MouseEvent/getModifierState --- <p id="Summary">{{APIRef("DOM Events")}}</p> <p>The <strong><code>MouseEvent.getModifierState()</code></strong> method returns the current state of the specified modifier key: <code>true</code> if the modifier is active (i.e., the modifier key is pressed or locked), otherwise, <code>false</code>.</p> <p>See the document of {{domxref("KeyboardEvent.getModifierState","KeyboardEvent.getModifierState()")}} for details.</p> <h2 id="语法">语法</h2> <pre class="syntaxbox">var <code><em>active</em> = <em>event</em>.getModifierState(<em>keyArg</em>);</code></pre> <h3 id="返回值">返回值</h3> <p>A {{jsxref("Boolean")}}</p> <h3 id="参数">参数</h3> <dl> <dt><em><code>keyArg</code></em></dt> <dd>A modifier key value. The value must be one of the {{domxref("KeyboardEvent.key")}} values which represent modifier keys or <code>"Accel"</code>. This is case-sensitive.</dd> </dl> <h2 id="规范"><a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Date#%E8%A7%84%E8%8C%83">规范</a></h2> <table class="standard-table"> <tbody> <tr> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> <tr> <td>{{SpecName('DOM3 Events', '#widl-MouseEvent-getModifierState', 'getModifierState()')}}</td> <td>{{Spec2('DOM3 Events')}}</td> <td>Initial definition.</td> </tr> </tbody> </table> <h2 id="浏览器兼容性">浏览器兼容性</h2> <p>{{Compat("api.MouseEvent.getModifierState")}}</p> <h2 id="See_also">See also</h2> <ul> <li>The {{domxref("MouseEvent")}} this method belongs to.</li> <li>{{domxref("KeyboardEvent.getModifierState")}}</li> </ul>