Help needed
So I’m build a drum machine as you can see from my code below I’m almost done however I’m trying to add an effet (pushed down ) on my keys, on my react code with either the mouse or with keyboard, but nothing happens except for the sound that comes out, it would seem that I’m missing something. If you could take a look and let me know what I’m missing it will be much appreciated.
Thanks.
You already have a rule in your CSS which styles the button when clicked; it isn’t working now because is commented out, but if you remove the /* */ you will see that the style of the buttons changes when clicked. However, if you want the same effect when you press the correspondent keyboard key, you’ll need to programmatically add and then remove a CSS class using the {element}.classList.toggle(’{class-name}’) method. Probably there are other ways to do that…this is the approach I used in styling my drum-machine app. Have a look at lines 28-29.
@Marco16168 Your suggestion to use classList.toggle is not really the “React” way of doing things. When all possible, you should not manipulate the DOM directly, which is what you are suggesting.
Hello guys!!
I know this is little late but i want to thank you again for your responses it was realy helpful im almost done but I haven’t quiet figured out everything yet, but neverthe less i’m making small progresse.
P.S. Don’t hesitate to checkout my work and let me know what you think overall!!!