Advertisements
Maybe someone can guide me in the right direction. I am trying to make logging happen if the Shift+key is pressed and not happen if only the Shift is pressed.
At the moment it works as expected, except that when I press Shift it also gets logged 🙁 Also tried to console.log(event.shiftKey)
but then getting "true" logged
document.addEventListener('keydown', (event)=> {
if(event.shiftKey && event.key) {
console.log(event.key)
}
})
>Solution :
Check key is not equal to shift
document.addEventListener('keydown', (event) => {
if (event.shiftKey && event.key !== "Shift") {
console.log(event.key)
}
})