概述
表明当事件触发时,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