ctrlkey 마우스 이벤트 속성은 마우스 버튼을 클릭했을 때 CTRL 키가 눌렸는지 여부를 표시하는 데 사용됩니다.
예시
다음 코드를 실행하여 ctrlKey 구현 방법을 배울 수 있습니다. JavaScript의 마우스 이벤트.
<!DOCTYPE html>
<html>
<body onmousedown="funcCtrlKey(event)">
<div>Press and hold CTRL key and then click here.</div>
<script>
function funcCtrlKey(event) {
if (event.ctrlKey) {
alert("CTRL key: Pressed");
} else {
alert("CTRL key: NOT Pressed");
}
}
</script>
</body>
</html>