-
[JavaScript] 키보드 이벤트: 특정키 확인 (key, code, keyCode)JavaScript 2022. 7. 18. 18:19
⌨️ KeyboardEvent.code
키보드의 물리적인 키 반환
입력 장치가 물리적 키보드가 아니라 가상 키보드 또는 접근성 장치인 경우 리턴값은 물리적 키보드에서 발생하는 것과 최대한 일치하도록 브라우저에서 설정하여 물리적 키보드 간의 호환성을 최대화한다.
이 속성은 해당 키와 연결된 문자가 아닌 입력 장치의 물리적 위치를 기반으로 키를 처리하려는 경우에 유용하다.
(키보드 키를 사용하는 게임의 입력을 처리하는 코드를 작성할 때)
⌨️ KeyboardEvent.key
사용자가 누른 키의 값 반환
⌨️ KeyboardEvent.keyCode
현재 Deprecated 이므로 권장되지 않는다.
key 값을 code로 반환한다.
반응형'JavaScript' 카테고리의 다른 글
[JavaScript] FileReader 객체 (0) 2022.09.11 [JavaScript] use strict (0) 2022.08.30 [JavaScript] var let const 차이점 (0) 2022.08.08 [JavaScript] Throttle 와 Debounce (0) 2022.06.23 [JavaScript] 브라우저 창 사이즈 (0) 2022.06.16