aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/mouseevent/metakey/index.html
blob: 3857a4f284a83822ffbef744ff6cb5a6f02859d7 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
---
title: MouseEvent.metaKey
slug: Web/API/MouseEvent/metaKey
translation_of: Web/API/MouseEvent/metaKey
---
<p>{{APIRef("DOM Events")}}</p>

<p><strong><code>MouseEvent.metaKey</code></strong> 为只读属性,返回一个 {{jsxref("Boolean", "布尔值")}},在鼠标事件发生时,用于指示 <kbd>Meta</kbd> 键是按下状态(<code>true</code>),还是释放状态(<code>false</code>)。</p>

<div class="note">
<p><strong>备注:</strong>在 MAC 键盘上,表示 Command 键(<kbd></kbd>),在 Windows键盘上,表示 Windows 键(<kbd></kbd>)。</p>
</div>

<h2 id="语法">语法</h2>

<pre class="syntaxbox">var metaKeyPressed = <em>instanceOfMouseEvent</em>.metaKey
</pre>

<h3 id="返回值">返回值</h3>

<p>一个布尔值。</p>

<h2 id="Example" name="Example">示例</h2>

<pre class="brush: js"> function goInput(e) {
 // 检测 metaKey 值
   if (e.metaKey) {
        // 继续处理事件
     superSizeOutput(e);
   } else {
     doOutput(e);
   }
 }
</pre>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">规范版本</th>
   <th scope="col">规范状态</th>
   <th scope="col">备注</th>
  </tr>
  <tr>
   <td>{{SpecName('DOM3 Events','#widl-MouseEvent-ctrlKey','MouseEvent.ctrlKey')}}</td>
   <td>{{Spec2('DOM3 Events')}}</td>
   <td>No change from {{SpecName('DOM2 Events')}}.</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM2 Events','#Events-MouseEvent','MouseEvent.ctrlKey')}}</td>
   <td>{{Spec2('DOM2 Events')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>

<p>{{ CompatibilityTable() }}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Firefox (Gecko)</th>
   <th>Chrome</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown()}}</td>
   <td>{{CompatVersionUnknown()}}</td>
   <td>{{CompatVersionUnknown()}}</td>
   <td>{{CompatVersionUnknown()}}</td>
   <td>{{CompatVersionUnknown()}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Android</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also" name="See_also">相关链接</h2>

<ul>
 <li>{{ domxref("MouseEvent") }}</li>
</ul>