What is the role of shiftKey mouse event in JavaScript?

PHPz
Release: 2023-08-26 14:25:02
forward
842 people have browsed it

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>
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template