ctrlLeft property
Sets or retrieves the state of the left CTRL 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.
Examples
The following example shows how to use the ctrlLeft property to indicate when the user presses the left or right CTRL keys.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/starLeft.htm
<head> <script> function init() { spanLeftCtrl.innerText='false'; spanRightCtrl.innerText='false'; } function indicate(obj, arg) { obj.innerText=arg; } function CtrlDown() { if (event.ctrlLeft) { indicate(spanLeftCtrl,'true'); } else { if (event.ctrlKey) { indicate(spanRightCtrl,'true'); } } } function CtrlUp() { if (!event.ctrlKey) { indicate(spanLeftCtrl,'false'); indicate(spanRightCtrl,'false'); } } </script> </head> <body onload="document.body.focus(); init()" onkeydown="CtrlDown();" onkeyup="CtrlUp();"> <p>Press either the left or right CTRL key.</p> <table> <tr> <td><i>Left CTRL Key Pressed</i></td> <td><i>Right CTRL Key Pressed</i></td> </tr> <tr> <td align="center"><span id="spanLeftCtrl"></span></td> <td align="center"><span id="spanRightCtrl"></span></td> </tr> </table> </body>
See also
Show: