altKey

收藏:0   阅读:19

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>

© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!