blob: c19bc41748269a1989436e9996994ddeb218e036 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
---
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>
|