event.shiftKey

hift« DOM Reference

Summary

Indicates whether the SHIFT key was pressed when the event fired.

Syntax

var bool = event.shiftKey;

bool contains true or false, depending on whether the shift key was held down or not, when the event fired.

Example

<html>
<head>
<title>shiftKey example</title>

<script type="text/javascript">

function showChar(e){
  alert(
    "Key Pressed: " + String.fromCharCode(e.charCode) + "\n"
    + "charCode: " + e.charCode + "\n"
    + "SHIFT key pressed: " + e.shiftKey + "\n"
    + "ALT key pressed: " + e.altKey + "\n"
  );
}

</script>
</head>

<body onkeypress="showChar(event);">
<p>Press any character key, with or without holding down
 the SHIFT key.<br />
You can also use the SHIFT key together with the ALT key.</p>
</body>
</html>

Specification

shiftKey

Document Tags and Contributors

Last updated by: kscarfone,