altKey 事件屬性
事件對象定義和用法
altKey 事件屬性返回一個布爾值。指示在指定的事件發(fā)生時,Alt 鍵是否被按下并保持住了。
語法
event.altKey=true|false|1|0
實例
實例
下面的例子可提示當鼠標按鍵被點擊時 "ALT" 鍵是否已被按?。?/p>
<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>
<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>
嘗試一下 ?
事件對象
更多建議: