For some reason, my key triggers for the drum machine project are effectively triggering my audio elements and updating the display text with no detectable delay, but test #6 refuses to pass. As far as I can tell, I fulfilled the specifications to the letter, but it’s telling me that no audio plays when ‘Q’ is pressed and I get audio when I press Q. Any idea what could be causing this?
Probably not without seeing your code.
As said, we need to see your code.
Are you using the <audio>
element or an Audio()
constructor? The tests require you use the element.
Hi there, I am experiencing the same issue
This is my code: https://codepen.io/giuliapassoni/pen/poadqrQ
As per the suggestion above, I’m using the HTML audio element.
Thanks in advance for your help
@kirakira95 It would be better if you opened your own thread. Anyway.
-
You do not have access to
this.handleKeyPress
inside theTest
component and there is no reason to call it inside it as you already have it listening on the document. Also, just as an aside don’t name the component Test. -
You should not assign
props
tostate
. Use the props directly (or create derived state from them).
- As far as I can tell, the bound function you are returning in the
keydown
handler will not be the same signature as the one you have for the event listener removal. I’d suggest binding the function in the constructor and passing the bound function to addEventListener/removeEventListener. I tested it by directly calling removeEventListener inside thehandleKeyPress
at the bottom to see if it gets removed or not.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.