<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="js/jquery-3.6.0.min.js"></script>
<script>
// 키보드를 눌렀을 때 이벤트 처리하는 방법
$('body').on('keydown',function(event){
console.log(event)
// keyCode만 가지고 오기
// keyCode를 통해 제어할 수 있다.
console.log(event.keyCode)
})
</script>
</body>
</html>
키보드 왼쪽 키 keyCode
키보드 오른쪽 키 keyCode
'JavaScript' 카테고리의 다른 글
[JavaScript] 조작메소드 (0) | 2022.05.31 |
---|---|
[JavaScript] 이벤트(이미지 움직이기) (0) | 2022.05.31 |
[JavaScript] jQuery (버튼 클릭 시 크기, 색상 변경) (0) | 2022.05.31 |
[JavaScript] jQuery (요소 가져오기) (0) | 2022.05.31 |
[JavaScript] jQuery 사용법 (0) | 2022.05.31 |