Can someone please help me understand or point me in the right direction this issue? For some reason I can’t get the audio to play when I click on each element. I think my issue is with the audio and play functions but I’m not sure.
Here’s a link to my code so far: https://codepen.io/skilledthunder/pen/pBmPZa?editors=0010
Sorry if my code looks messy, I’m still pretty new to React. Any help would be much appreciated.
So there’s a simple fix to “pass the test”. For that see https://reactjs.org/docs/events.html#keyboard-events
Unfortunately, I haven’t been able to get your example to actually make a sound when a key is pressed, and I’ve hit the end of my day But, before I crawl into bed, I did want to share some of what I learned (I’m a Vue dev, not React dev, so some of this may be obvious to you, but it wasn’t to me).
- You can’t use a keyboard event on a vanilla
div
.
- There are supposedly several ways to make a vanilla
div
work with keyboard events
- You can’t just log out the event data that’s passed by the keyboard event, but there are a couple of ways to work around this
And with that I must say:
1 Like