Using the mouse to play notes on our piano works okay, but it would be better if we could play more than one note at a time. To do that, we can use the computer's keyboard to play notes. To do this we will add keyboard event handlers to the DOM
The top two rows of the keyboard will be used for the first octave and the bottom two for the second octave. For example, pressing the Q key will play the lowest C note. Pressing the 2 key will play C#, W will play D, and so on. For the second octave, pressing Z will play middle C, S will play C#, and so on:
You can find the code for ...