--- title: MouseEvent.ctrlKey slug: Web/API/MouseEvent/ctrlKey translation_of: Web/API/MouseEvent/ctrlKey ---
{{APIRef("DOM Events")}}
読み取り専用プロパティ MouseEvent.ctrlKey は、イベント発生時に control キーが押されたかどうかを、押されていた (true) または押されていない (false) の{{jsxref("Boolean")}} で返します。
var ctrlKeyPressed = instanceOfMouseEvent.ctrlKey
A boolean
<html>
<head>
<title>ctrlKey使用例</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>何か文字キーを単体またはCTRLキーと同時に押してください。<br />
また、CTRLキーに加え、SHIFTキーも同時に使用できます。</p>
</body>
</html>
| Specification | Status | Comment |
|---|---|---|
| {{SpecName('DOM3 Events','#widl-MouseEvent-ctrlKey','MouseEvent.ctrlKey')}} | {{Spec2('DOM3 Events')}} | {{SpecName('DOM2 Events')}}から変更なし |
| {{SpecName('DOM2 Events','#Events-MouseEvent','MouseEvent.ctrlKey')}} | {{Spec2('DOM2 Events')}} | 最初期の定義 |
{{Compat("api.MouseEvent.ctrlKey")}}