altKey

altKey 事件属性


定义和用法

altKey 事件属性返回一个布尔值。指示在指定的事件发生时,Alt 键是否被按下并保持住了。

语法

event.altKey=true|false|1|0


实例

下面的例子可提示当鼠标按键被点击时 "ALT" 键是否已被按住:

<html>
<head>
<script>
function isKeyPressed(event)
{
if (event.altKey==1)
{
alert("The ALT key was pressed!")
}
else
{
alert("The ALT key was NOT pressed!")
}
}
</script>
</head>

<body onmousedown="isKeyPressed(event)">

<p>Click somewhere in the document.
An alert box will tell you if you
pressed the ALT key or not.</p>

</body>
</html>

© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3