shiftKey鼠标事件在JavaScript中的作用是什么?

原创
ithorizon 5个月前 (10-19) 阅读数 46 #HTML

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>

以上就是shiftKey鼠标事件在JavaScript中的作用是什么?的详细内容,更多请关注IT视界其它相关文章!



热门