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