From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/event.altkey/index.html | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 files/zh-cn/web/api/event.altkey/index.html (limited to 'files/zh-cn/web/api/event.altkey') diff --git a/files/zh-cn/web/api/event.altkey/index.html b/files/zh-cn/web/api/event.altkey/index.html new file mode 100644 index 0000000000..10b91aab4f --- /dev/null +++ b/files/zh-cn/web/api/event.altkey/index.html @@ -0,0 +1,43 @@ +--- +title: event.altKey +slug: Web/API/event.altKey +translation_of: Web/API/MouseEvent/altKey +--- +

{{ ApiRef() }}

+

概述

+

表明当事件触发时,ALT键是否处于按下的状态.

+

语法

+
event.altKey
+
+

例子

+
var bool = event.altKey;
+
+

如果当事件触发时,ALT键处于按下的状态,则bool的值为true,否则为false.

+
<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>
+
+

规范

+

DOM Level 2 Events - property of MouseEvent object

+

{{ languages( { "ja": "ja/DOM/event.altKey", "pl": "pl/DOM/event.altKey", "en": "en/DOM/event.altKey" } ) }}

-- cgit v1.2.3-54-g00ecf