요약: keyCode 대신 code를 사용하자
KeyboardEvent: keyCode
KeyboardEvent: keyCode property - Web APIs | MDN
The deprecated KeyboardEvent.keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key.
developer.mozilla.org
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
(Deprecated(사용하지 않음): 이 기능은 더 이상 권장 안 함. 일부 브라우저는 여전히 지원할 수 있지만 웹 표준에서 이미 제거되었거나 삭제 중이거나 호환성 목적으로만 유지될 수 있으니, 사용을 피하고 가능하면 기존 코드를 업데이트 하는게 좋을껄? keyCode는 언제든지 작동하지 않을 수 있음 주의~)
You should avoid using this if possible; it's been deprecated for some time. Instead, you should use KeyboardEvent.code, if it's implemented. Unfortunately, some browsers still don't have it, so you'll have to be careful to make sure you use one which is supported on all target browsers.
(대신 KeyboardEvent.code를 써야하는데,
일부 브라우저는 아직 지원 안 할 수도 있음.)
KeyboardEvent: code
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code
KeyboardEvent: code property - Web APIs | MDN
The KeyboardEvent.code property represents a physical key on the keyboard (as opposed to the character generated by pressing the key). In other words, this property returns a value that isn't altered by keyboard layout or the state of the modifier keys.
developer.mozilla.org
KeyboardEvent: key
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
KeyboardEvent: key property - Web APIs | MDN
The KeyboardEvent interface's key read-only property returns the value of the key pressed by the user, taking into consideration the state of modifier keys such as Shift as well as the keyboard locale and layout.
developer.mozilla.org
아무튼, 그동안 keyCode로 사용하고 있었는데, 틈틈히 코드 업데이트를 진행해야 할 듯.
'웹 스터디노트 > Script' 카테고리의 다른 글
타입스크립트 핸드북, 윈터루드님의 (0) | 2023.07.10 |
---|---|
[ js ] 스크립트 동적 생성하기 (0) | 2023.04.25 |
[ js ] defer vs async (0) | 2023.04.25 |
[ js ] 크로스도메인에서 iframe 높이값 자동 처리하기 (0) | 2023.03.02 |
javascript로 style 삭제 방법 (0) | 2023.01.02 |
[자바스크립트] Keycode 이벤트 코드값 (1) | 2022.12.28 |
slick slider 사용법과 옵션 (0) | 2022.12.28 |
[js] 시크릿 모드 체크하기 예시 (0) | 2022.12.22 |
댓글