JavaScript 中 shiftKey 鼠标事件的作用是什么?
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>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP