Latest web development tutorials

altKey event properties

Event Object Reference Event objects

Definition and Usage

altKey event attribute returns a Boolean value. Indicate when a specified event occurs, Alt key is pressed and hold up.

grammar

event.altKey=true|false|1|0


Examples

Examples

The following example prompts when the mouse button is clicked "ALT" key is pressed whether:

<html>
<head>
<script>
function isKeyPressed(event)
{
if (event.altKey==1)
{
alert("The ALT key was pressed!")
}
else
{
alert("The ALT key was NOT pressed!")
}
}
</script>
</head>

<body onmousedown="isKeyPressed(event)">

<p>Click somewhere in the document.
An alert box will tell you if you
pressed the ALT key or not.</p>

</body>
</html>

try it"


Event Object Reference Event objects