blob: 382f62201d56e07fbd4b61df074870ea6080eec5 (
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
|
---
title: event.altKey
slug: conflicting/Web/API/MouseEvent/altKey
translation_of: Web/API/MouseEvent/altKey
translation_of_original: Web/API/event.altKey
original_slug: Web/API/event.altKey
---
<p>{{ ApiRef() }}</p>
<h3 id="Summary" name="Summary">概述</h3>
<p>表明当事件触发时,ALT键是否处于按下的状态.</p>
<h3 id="Syntax" name="Syntax">语法</h3>
<pre class="eval">event.altKey
</pre>
<h3 id="例子">例子</h3>
<pre><code><em>var bool</em> = event.altKey;</code>
</pre>
<p>如果当事件触发时,ALT键处于按下的状态,<code style="font-family: 'Courier New','Andale Mono',monospace; font-style: normal; font-variant: normal; font-size: 100%; line-height: normal; color: inherit; font-weight: inherit;">则bool</code>的值为<code style="font-family: 'Courier New','Andale Mono',monospace; font-style: normal; font-variant: normal; font-size: 100%; line-height: normal; color: inherit; font-weight: inherit;">true,否则为</code><code style="font-family: 'Courier New','Andale Mono',monospace; font-style: normal; font-variant: normal; font-size: 100%; line-height: normal; color: inherit; font-weight: inherit;">false</code>.</p>
<pre class="brush: html"><html>
<head>
<title>altKey 示例</title>
<script type="text/javascript">
function showChar(e){
alert(
"按下的键: " + String.fromCharCode(e.charCode) + "\n"
+ "charCode: " + e.charCode + "\n"
+ "是否按下ALT键: " + e.altKey + "\n"
);
}
</script>
</head>
<body onkeypress="showChar(event);">
<p>
按下一个字符键,尝试同时按下ALT键.<br />
你也可以同时按下SHIFT键和ALT键.
</p>
</body>
</html>
</pre>
<h3 id="规范">规范</h3>
<p>DOM Level 2 Events - property of MouseEvent object</p>
<p>{{ languages( { "ja": "ja/DOM/event.altKey", "pl": "pl/DOM/event.altKey", "en": "en/DOM/event.altKey" } ) }}</p>
|