I want to trigger code with different key presses:
document.addEventListener("keydown", event => {
;(async () => {
if (event.key === 'b' && event.ctrlKey) {
alert('1')
} else if (event.code === 'Space' && event.ctrlKey) {
alert('2')
} else if (event.code === 'q' && event.ctrlKey) {
alert('3')
}
})()
})
The strange thing is that the last if statement won't trigger. Even if I swap b for q.
What could be the reason?
There are no errors whatsoever.
Aucun commentaire:
Enregistrer un commentaire