You are here: Reference > JavaScript > client-side > event handling > properties > shiftKey (event)

shiftKey property (event)

Browser support:
Sets or retrieves a Boolean value that indicates whether the left or right SHIFT key was down at the time when the event occurred.
In Internet Explorer, use the shiftLeft property to detect whether the left or right SHIFT key is down.
For ALT and CTRL keys, use the altKey and ctrlKey properties.

Syntax:

object.shiftKey;
You can find the related objects in the Supported by objects section below.
The shiftKey property is read-only, except if the event object is created with the createEventObject method when it is read/write.

Possible values:

Boolean that sets or retrieves the state of the SHIFT key.
One of the following values:
false
SHIFT key is up.
true
SHIFT key is down.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the shiftKey property:
<head>
    <script type="text/javascript">
        function GetShiftState (event) {
            if (event.shiftKey) {
                alert ("Shift key is down.");
            }
            else {
                alert ("Shift key is up.");
            }
        }
    </script>
</head>
<body>
    Press and hold down the SHIFT key before you click on the button.
    <br />
    <button onclick="GetShiftState (event);">Get Shift key state!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content