Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

altKey Event Attribute

altKey Event Attribute

Event Object Reference Event Object


Definition and Usage

The altKey event attribute returns a Boolean value. It indicates whether the Alt key was pressed and held down when the specified event occurred.

Syntax

event.altKey=true|false|1|0


Example

Example

The following example alerts whether the "ALT" key was held down when a mouse button is clicked:

function

isKeyPressed

(

event

)

{

if

(

event

.

altKey

==

1

)

{

alert

(

"

The ALT key is pressed!

"

)

;

}

else

{

alert

(

"

The ALT key is not pressed!

"

)

;

}

}

Try it »


Event Object Reference Event Object