Add New Feature: Allows the piano to produce corresponding sounds when played the piano. NO JavaScript. #1017
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello. I am a student majoring in computer science and I'm also a music enthusiast. When I ran this piano project, I found that it couldn't produce the sound corresponding to each key, so I wanted to implement this functionality. I started by importing the sounds folder, which contains audio files for three octaves of the piano, from C3 to B5. And then, I begin to work with the code.In the code, each key has an embedded audio element, and the audio element is positioned at the bottom of the key using CSS. Additionally, other controls except the play button are hidden via CSS pseudo-element selectors. This way, users can see a play button at the bottom of each key, and clicking it will play the corresponding note.
However, the original code does not allow clicking the entire key (rather than just the play button) to play the sound. This is because JavaScript WAS NOT USED to bind a click event to the entire key.