aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/event.shiftkey/index.html
blob: 1c79d02d0acea560c62f7d57efed045fcc36d7da (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
---
title: event.shiftKey
slug: Web/API/event.shiftKey
translation_of: Web/API/MouseEvent/shiftKey
---
<p>{{ ApiRef() }}</p>
<h3 id="Summary" name="Summary">概述</h3>
<p>表明当事件触发时,SHIFT键是否处于按下状态.</p>
<h3 id="Syntax" name="Syntax">语法</h3>
<pre class="eval"><em>var bool</em> = event.shiftKey;
</pre>
<p><code>bool</code> 的值为 <code>true</code><code>false</code></p>
<h3 id="Example" name="Example">例子</h3>
<pre>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;shiftKey example&lt;/title&gt;

&lt;script type="text/javascript"&gt;

function showChar(e){
  alert(
    "Key Pressed: " + String.fromCharCode(e.charCode) + "\n"
    + "charCode: " + e.charCode + "\n"
    + "SHIFT key pressed: " + e.shiftKey + "\n"
    + "ALT key pressed: " + e.altKey + "\n"
  );
}

&lt;/script&gt;
&lt;/head&gt;

&lt;body onkeypress="showChar(event);"&gt;
&lt;p&gt;<span>按下一个字符键,尝试同时按下</span>SHIFT<span>键.</span>&lt;br /&gt;
<span>你也可以同时按下SHIFT键和ALT键.</span>&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h3 id="Specification" name="Specification">规范</h3>
<p><a class="external" href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-MouseEvent-shiftKey">shiftKey </a></p>
<p>{{ languages( { "pl": "pl/DOM/event.shiftKey" ,"en": "en/DOM/event.shiftKey" } ) }}</p>