Drum Machine project issue

I can’t get test 6 to pass. Test 5 passes, but only after all buttons are manually triggered at least once, either via keyboard or clicking each button.

Do I need to associate the keypresses with clicking each button in a different way or something? :confused:

Try logging out event.keyCode in your handler and run the tests.

Huh. I see that the test runs with an event.keyCode of 81, which is what I expected based on my research (every resource I found said “Q” would have a key code of 81), but whenever I logged event.keyCode when I pressed my own keyboard, it was 113. Not sure why. (Does it have to do with the fact that I’m on Ubuntu? And/or the fact that I’m using Firefox? :man_shrugging:)

Regardless, the tests pass if I instead switch over event.code (which looks like KeyQ, KeyW, etc.), so thanks for your help lasjorg!

Btw in case anybody else has this issue, I’m using the inspect element console to see the contents of the event object with console.log(event). Very handy that I can see all props/methods of an object that way.

It is the difference between

'q'.charCodeAt() // 113
'Q'.charCodeAt() // 81

I would suggest using key when at all possible.

Ah okay, thanks. I even read that MDN article, but somehow it didn’t register with me that Shift is taken into account. :expressionless:
Thanks though!

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