A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-mouseevent-shiftkey-property/ below:

JavaScript MouseEvent shiftKey Property - GeeksforGeeks

JavaScript MouseEvent shiftKey Property

Last Updated : 08 Feb, 2023

The mouseEvent shiftKey property is used to define whether the shift key is pressed or not. It is a boolean value. When the shift key is pressed then on click of the mouse left button, it returns true and if the shift key is not pressed then it returns false. 

Syntax:

event.shiftKey

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

Example: In this example, we will see the example of MouseEvent shiftKey property.

html
<body style="text-align:center;">

    <h1 style="color:green;">
        GeeksforGeeks
    </h1>

    <h2>
        mouseEvent shiftKey Property
    </h2>

    <button onclick="geek (event);">Get Shift key state!</button>
    <p id="gfg"></p>
    <script>
        function geek (event) {
            if (event.shiftKey) {
                document.getElementById("gfg").innerHTML= "Shift key is pressed.";
            }
            else {
                document.getElementById("gfg").innerHTML= "Shift key is not pressed.";
            }
        }
    </script>
</body>

Output:

JavaScript MouseEvent shiftKey Property

Supported Browsers: The browser supported by shiftKey properties are listed below:



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4