How do i get the sound to play on pressing a certain key

Hello, I am trying to get the sound within an anchor tag to play when a key that corresponds to it is pressed in the Drum Pad project. I’ve to do this

function handleKeyDown(event) {

and i attached this function to an event listener on the main div of my react app

Also, the sound effect fires off when i click on the “Run Tests” button and i have no idea why.

Here is a link to my code

I had a similar problem a few days ago, and I found react key handler, sends you to npm website but you can also install it with npm install react-key-handler.

If you are trying to do it with react you can use React.createRef().

Thank you. This didn’t really work for me. I need to read up on it to use it properly i guess. I was able to access the DOM node. But not in the way i wanted to

I honestly cannot understand how to use it
thank you though