728x90
Beacuse of event.keyCode is deprecated.
It means we are not supposed to use that code in our project.
Then how can we change code properly.
Before.
document.addEventListener("keyup", (e) => {
if (e.keyCode == 37) {
some code...
}
})
It should be updated like this.
document.addEventListener("keyup", (e) => {
if (e.key == "ArrowLeft") {
some code...
}
})
Then we have one question left, how can we know key name?
The easiest way is looking mdn.
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
See for youself.
728x90
'IT' 카테고리의 다른 글
replit vscode ssh error, connect timeout, enter password (0) | 2024.10.31 |
---|---|
마이크로오피스가 관리자 권한으로만 실행 될 때 해결 방법 (0) | 2024.06.21 |
nuxt-auth/next-auth의 끔찍한 rotation refresh token 문제 (0) | 2023.08.01 |
hot to fix poetry self update error (0) | 2022.12.16 |
vscode에서 eslint와 prettier을 동시사용문제 (0) | 2022.11.27 |