ctrlKey 事件屬性
定義和用法
ctrlKey 事件屬性可返回一個布爾值,指示當(dāng)事件發(fā)生時,Ctrl 鍵是否被按下并保持住。
語法
event.ctrlKey=true|false|1|0
實(shí)例
下面的例子可提示當(dāng)鼠標(biāo)按鍵被點(diǎn)擊時 "CTRL" 鍵是否被按。
<html>
<head>
<script type="text/javascript">
function isKeyPressed(event)
{
if (event.ctrlKey==1
)
{
alert("The CTRL key was pressed!")
}
else
{
alert("The CTRL 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 CTRL key or not.</p>
</body>
</html>
TIY
- ctrlKey
- 檢測 CTRL 鍵是否被按下了。