ctrlKey

« DOM Reference

Summary

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

Syntax

var bool = event.ctrlKey;

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

Example

<html>
<head>
<title>ctrlKey example</title>

<script type="text/javascript">

function showChar(e){
  alert(
    "Key Pressed: " + String.fromCharCode(e.charCode) + "\n"
    + "charCode: " + e.charCode + "\n"
    + "CTRL key pressed: " + e.ctrlKey + "\n"
  );
}

</script>
</head>

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

Specification

ctrlKey

 

Document Tags and Contributors

 Last updated by: Dria,