Skip to content
Related Articles

Related Articles

Javascript | MouseEvent ctrlKey Property

Improve Article
Save Article
  • Difficulty Level : Hard
  • Last Updated : 07 Jan, 2019
Improve Article
Save Article

The mouseEvent ctrlKey property is used to define whether the ctrl key is pressed or not. It is a boolean value. When ctrl key is pressed then on click of the mouse buttons it returns true and if it is not pressed then it returns false.



Return Value: It returns a boolean value indicating whether ctrl key is pressed or not.

  • true: it indicates ctrl key is pressed.
  • false: it indicates ctrl key is not pressed.

Example :

<!DOCTYPE html>
        <title>JavaScript Mouse Event</title>
    <body style = "text-align:center;">
        <h1 style = "color:green;">
            mouseEvent ctrlKey Property
        <button onclick="geek (event);">Get Ctrl key state!</button>        
        function geek (event) {
            if (event.ctrlKey) {
                alert ("Ctrl key is pressed.");
            else {
                alert ("Ctrl key is not pressed.");

Clicking button (ctrl key is not pressed):
Clicking button (ctrl key is pressed):

Supported Browsers: The browser supported by ctrlKey property are listed below:

  • Apple Safari
  • Google Chrome
  • Firefox
  • Opera
  • Internet Explorer
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!