JavaScript MouseEvent ctrlKey Property

The mouseEvent ctrlKey property is used to define whether the ctrl key is pressed or not. It is a boolean value. When the ctrl key is pressed then on click of the mouse buttons it returns true and if it is not pressed then it returns false.
Syntax:
event.ctrlKey
Return Value: It returns a boolean value indicating whether the ctrl key is pressed or not.
- true: it indicates the ctrl key is pressed.
- false: it indicates the ctrl key is not pressed.
Example: In this example, we will see the example of MouseEvent ctrlKey property.
html
| <bodystyle="text-align:center;">     <h1style="color:green;">         zambiatek     </h1>      <h2>         mouseEvent ctrlKey Property     </h2>     <buttononclick="geek (event);">Get Ctrl key state!</button>     <pid="gfg"></p>     <script>         function geek (event) {             if (event.ctrlKey) {                 document.getElementById("gfg")                         .innerHTML = "Ctrl key is pressed.";             }             else {                 document.getElementById("gfg")                         .innerHTML= ("Ctrl key is not pressed.");             }         }     </script> </body> | 
Output:
 
Javascript MouseEvent ctrlKey PropertyJavascript MouseEvent ctrlKey Property
Supported Browsers: The browser supported by the ctrlKey property are listed below:
- Apple Safari
- Google Chrome
- Firefox
- Opera
- Internet Explorer
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
 
				 
					


