--- title: event.altKey slug: Web/API/event.altKey translation_of: Web/API/MouseEvent/altKey translation_of_original: Web/API/event.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" } ) }}