PressandholdSHIFTkey"/>    
PressandholdSHIFTkey">

首頁  >  文章  >  web前端  >  shiftKey滑鼠事件在JavaScript中的作用是什麼?

shiftKey滑鼠事件在JavaScript中的作用是什麼?

PHPz
PHPz轉載
2023-08-26 14:25:02783瀏覽

shiftKey滑鼠事件在JavaScript中的作用是什麼?

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中的作用是什麼?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除