I am trying to complete my drum machine and just not getting the keypress function to work. What am I doing wrong?
it is working as expected.
What am I doing wrong?
you see, you have the name prop in each Drums component defined as a capital letter. Therefore if you press SHIFT+key then it plays the sound. Otherwise, just change each name prop to be a lowercase letter .
Change this:
e.key === this.props.name
to this:
e.key.toLowerCase() === this.props.name.toLowerCase()
so you always comparing a lower case letters to lower case letters.