From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../zh-cn/web/api/keyboardevent/altkey/index.html | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 files/zh-cn/web/api/keyboardevent/altkey/index.html (limited to 'files/zh-cn/web/api/keyboardevent/altkey') diff --git a/files/zh-cn/web/api/keyboardevent/altkey/index.html b/files/zh-cn/web/api/keyboardevent/altkey/index.html new file mode 100644 index 0000000000..0987f3ea89 --- /dev/null +++ b/files/zh-cn/web/api/keyboardevent/altkey/index.html @@ -0,0 +1,126 @@ +--- +title: KeyboardEvent.altKey +slug: Web/API/KeyboardEvent/altKey +tags: + - API + - DOM + - KeyboardEvent + - events + - 鼠标事件 +translation_of: Web/API/KeyboardEvent/altKey +--- +

{{APIRef("DOM Events")}}

+ +

KeyboardEvent.altKey 只读属性返回一个 {{jsxref("Boolean")}} 值,表示事件触发时 alt 键 (OS X系统上的 Option 或  键) 是 (true) 否 (false) 被按下。

+ +

语法

+ +
var altKeyPressed = instanceOfKeyboardEvent.altKey
+
+ +

返回值

+ +

布尔值

+ +

示例

+ +
<html>
+<head>
+<title>altKey example</title>
+
+<script type="text/javascript">
+
+function showChar(e){
+  alert(
+    "Key Pressed: " + String.fromCharCode(e.charCode) + "\n"
+    + "charCode: " + e.charCode + "\n"
+    + "ALT key pressed: " + e.altKey + "\n"
+  );
+}
+
+</script>
+</head>
+
+<body onkeypress="showChar(event);">
+<p>
+Press any character key,
+with or without holding down the ALT key.<br />
+You can also use the SHIFT key together with the ALT key.
+</p>
+</body>
+</html>
+ +

标准

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM3 Events','#widl-KeyboardEvent-altKey','KeyboardEvent.altkey')}}{{Spec2('DOM3 Events')}}Initial definition.
+ +

浏览器兼容性

+ +

{{ CompatibilityTable() }}

+ +
特性 + + + + + + + + + + + + + + + + + + + + +
EdgeFirefox (Gecko)ChromeInternet ExplorerOperaSafari
基本支持{{CompatVersionUnknown}}{{CompatVersionUnknown()}}{{CompatVersionUnknown()}}{{CompatVersionUnknown()}}{{CompatVersionUnknown()}}{{CompatVersionUnknown()}}
+
+ +
特性 + + + + + + + + + + + + + + + + + + + + +
EdgeFirefox Mobile (Gecko)AndroidIE MobileOpera MobileSafari Mobile
基本支持{{CompatVersionUnknown}}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}
+
+ +

参考

+ + -- cgit v1.2.3-54-g00ecf