MouseEvent.ctrlKey
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Свойство только для чтения MouseEvent.ctrlKey
возвращает true, когда клавиша Ctrl была нажата, а если нет - false.
Синтаксис
var ctrlKeyPressed = instanceOfMouseEvent.ctrlKey
Возвращаемое значение
Boolean
Пример
js
<html>
<head>
<title>Пример с ctrlKey</title>
<script type="text/javascript">
document.addEventListener('click', function(e) {
console.log('Нажата клавиша Ctrl?', e.ctrlKey);
})
</script>
</head>
<body>
<p>
Кликните в любое место на странице и откройте консоль разработчика, чтобы узнать - нажата ли клавиша Ctrl?
</p>
</body>
</html>
Спецификации
Specification |
---|
UI Events # dom-mouseevent-ctrlkey |
Совместимость с браузерами
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
ctrlKey |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.