Example
Find out whether or not the "CTRL" key was pressed when a keyboard key is pressed:
var x = document.getElementById("demo");
if (event.ctrlKey) {
x.innerHTML = "The CTRL key was pressed!";
} else {
x.innerHTML = "The CTRL key was NOT pressed!";
}
Try it Yourself »
Definition and Usage
The ctrlKey property returns a Boolean value that indicates whether or not the "CTRL" key was pressed when a key event was triggered.
Note: This property is read-only.
Browser Support
Property | |||||
---|---|---|---|---|---|
ctrlKey | Yes | Yes | Yes | Yes | Yes |
Syntax
event.ctrlKey
Technical Details
Return Value: |
A Boolean, indicating whether the "CTRL" key was pressed when the
key event occured.
Possible values:
|
---|---|
DOM Version: | DOM Level 2 Events |
Related Pages
HTML DOM reference: KeyboardEvent altKey Property
HTML DOM reference: KeyboardEvent metaKey Property
HTML DOM reference: KeyboardEvent shiftKey Property
< Event Object