shiftKey鼠标事件在JavaScript中起什么作用?
shiftkey鼠标事件属性用于显示单击鼠标按钮时是否按下SHIFT键。
示例
您可以尝试运行以下代码,以了解如何在JavaScript中实现shiftKey Mouse事件。
<!DOCTYPE html>
<html>
<body onmousedown = "funcShiftKey(event)">
<div>Press and hold SHIFT key and then click here.</div>
<script>
function funcShiftKey(event) {
if (event.shiftKey) {
alert("SHIFT key: Pressed");
} else {
alert("SHIFT key: NOT Pressed");
}
}
</script>
</body>
</html>