My keydown event listener works fine except for the Spacebar

I’m using keydown to trigger the flipping of a card and it works for every key - easy enough. It also works for the Spacebar but clicking the Spacebar also pages down to the next section of the page.

I have tabindex=“0” set on the card so it has focus. Is there a way to prevent the page down effect when a user clicks Spacebar?

my instincts is e.preventDefault() when keycode matches the keycode of a spacebar.

BINGO! Totally worked - thanks!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.