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

altKey property (event)

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


You can find the related objects in the Supported by objects section below.
The altKey property is read-only in, 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 ALT key.
One of the following values:
ALT key is up.
ALT key is down.
Default: this property has no default value.

Example HTML code 1:

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

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content