Sự kiện phím tắt kích hoạt khi nhấn một phím. Bạn có thể thử chạy mã sau để tìm hiểu cách làm việc với onkeydown sự kiện trong JavaScript -
Ví dụ
<html>
<head>
<script>
<!--
function sayHello() {
alert("A key is pressed.")
}
//-->
</script>
</head>
<body>
<input type = "text" onkeydown = "sayHello()">
</body>
</html>