altLeft property
Retrieves a value that indicates the state of the left ALT key.
Syntax
| JavaScript | |
|---|
Property values
Type: Boolean
Remarks
This property is currently supported only in Microsoft Windows NT 4.0 and Windows 2000.
The document must have focus for this property to return true.
No altRight property is available. Authors can test for the right ALT key by using the altKey and altLeft properties.
Examples
The following example shows how to use the altLeft property to indicate when the user presses the left or right ALT keys.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/starLeft.htm
<head> <script> function init() { spanLeftAlt.innerText='false'; spanRightAlt.innerText='false'; } function indicate(obj, arg) { obj.innerText=arg; } function AltDown() { if (event.altLeft) { indicate(spanLeftAlt,'true'); } else { if (event.altKey) { indicate(spanRightAlt,'true'); } } } function AltUp() { if (!event.altKey) { indicate(spanLeftAlt,'false'); indicate(spanRightAlt,'false'); } } </script> </HEAD> <body onload="document.body.focus(); init()" onkeydown="AltDown();" onkeyup="AltUp();"> <p>Press either the left or right ALT key.</p> <table> <tr> <td><i>Left ALT Key Pressed</i></td> <td><i>Right ALT Key Pressed</i></td> </tr> <tr> <td align="center"><span id="spanLeftAlt"></span></td> <td align="center"><span id="spanRightAlt"></span></td> </tr> </table> </body>
See also
Show: