Is the Shift pressed during the event : Key Event « Event « JavaScript Tutorial






<html>
<head>
<title>Key Events Example</title>
<script type="text/javascript">
function handleEvent(oEvent) {
    var oTextbox = document.getElementById("txt1");
    oTextbox.value += "\n>" + oEvent.type;
    oTextbox.value += "\n    target is " + (oEvent.target || oEvent.srcElement).id;
    oTextbox.value += "\n    charCode is " + oEvent.charCode;

    var arrKeys = [];
    if (oEvent.shiftKey) {
        arrKeys.push("Shift");
    }
    oTextbox.value += "\n    keys down are " + arrKeys;
}
</script>
</head>
<body>
    <P>Type some characters into the first textbox.</p>
    <P><textarea id="txtInput" rows="15" cols="50"
        onkeypress="handleEvent(event)"></textarea></p>
    <P><textarea id="txt1" rows="15" cols="50"></textarea></p>
</body>
</html>








15.7.Key Event
15.7.1.onkeydown key event handler
15.7.2.onkeyup key event handler
15.7.3.onkeypress key event handler
15.7.4.Display key event code in status bar (IE)
15.7.5.Use String.fromCharCode to convert key event code to key event char (IE)
15.7.6.Get key code
15.7.7.Get key char
15.7.8.Is Control pressed during the event
15.7.9.Is Alt pressed during the event
15.7.10.Is the Shift pressed during the event
15.7.11.Keystroke detector
15.7.12.Focus lost event