shiftLeft property
Retrieves the state of the left SHIFT key.
Syntax
| JavaScript | |
|---|
Property values
Type: Boolean
Remarks
The document must have focus for this property to return true.
Examples
The following example shows how to use the shiftLeft property to indicate when the user presses the left or right SHIFT keys.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/starLeft.htm
<head> <script> function init() { spanLeftShift.innerText='false'; spanRightShift.innerText='false'; } function indicate(obj, arg) { obj.innerText=arg; } function ShiftDown() { if (event.shiftLeft) { indicate(spanLeftShift,'true'); } else { if (event.shiftKey) { indicate(spanRightShift,'true'); } } } function ShiftUp() { if (!event.shiftKey) { indicate(spanLeftShift,'false'); indicate(spanRightShift,'false'); } } </script> </head> <body onload="document.body.focus(); init()" onkeydown="ShiftDown();" onkeyup="ShiftUp();"> <p>Press either the left or right SHIFT key.</p> <table> <tr> <td><i>Left SHIFT Key Pressed</i></td> <td><i>Right SHIFT Key Pressed</i></td> </tr> <tr> <td align="center"><span id="spanLeftShift"></span></td> <td align="center"><span id="spanRightShift"></span></td> </tr> </table> </body>
See also
Show: