JavaScript 中 shiftKey 鼠标事件的作用是什么?
htmljavascriptprogramming scripts更新于 2026/1/14 9:48:17
shiftkey 鼠标事件属性用于显示单击鼠标按钮时是否按下 SHIFT 键。
示例
您可以尝试运行以下代码来了解如何在 JavaScript 中实现 shiftKey 鼠标事件。
<!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>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

