PressandholdSHIFTkey"/>
PressandholdSHIFTkey">

Home  >  Article  >  Web Front-end  >  What is the role of shiftKey mouse event in JavaScript?

What is the role of shiftKey mouse event in JavaScript?

PHPz
PHPzforward
2023-08-26 14:25:02827browse

What is the role of shiftKey mouse event in JavaScript?

#shiftkey mouse event property is used to display whether the SHIFT key was pressed when the mouse button was clicked.

Example

You can try running the following code to learn how to implement the shiftKey mouse event in JavaScript.

<!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>

The above is the detailed content of What is the role of shiftKey mouse event in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete