What is the role of altKey Mouse Event in JavaScript?

HTMLJavascriptProgramming Scripts

The altkey mouse event property is used to show whether SHIFT key is pressed or not when mouse button is clicked.

Example

You can try to run the following code to learn how to implement altKey Mouse event in JavaScript.

<!DOCTYPE html>
<html>
   <body onmousedown="funcAltKey(event)">
      <div>Press and hold ALT key and then click here.</div>
      <script>
         function funcAltKey(event) {
            if (event.altKey) {
               alert("ALT key: Pressed");
            } else {
               alert("ALT key: NOT Pressed");
            }
         }
      </script>
   </body>
</html>
raja
Published on 26-Feb-2018 11:41:48
Advertisements