-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
50 lines (38 loc) · 1000 Bytes
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
title: "KeyboardEvent: ctrlKey property"
short-title: ctrlKey
slug: Web/API/KeyboardEvent/ctrlKey
page-type: web-api-instance-property
browser-compat: api.KeyboardEvent.ctrlKey
---
{{APIRef("UI Events")}}
The **`KeyboardEvent.ctrlKey`** read-only property returns a
boolean value that indicates if the <kbd>control</kbd> key was pressed
(`true`) or not (`false`) when the event occurred.
## Value
A boolean value.
## Examples
```html
<html lang="en">
<head>
<title>ctrlKey example</title>
<script>
function showChar(e) {
alert(`Key Pressed: ${e.key}\nCTRL 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>
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{ domxref("KeyboardEvent") }}