Guide
Playing a piano keyboard in the browser: computer-key mapping, sounds and sustain
A piano is the easiest way to see how music is arranged, and you do not need one: the keys of a laptop are enough to play a tune. This page draws a keyboard that responds to a mouse, a finger or a computer keyboard. You can use it to find a melody by ear, to check a note before singing it, to show a child where middle C is, or for a quick idea when no instrument is nearby.
Playing
Click or tap a key, or drag across several keys for a glissando. With the computer keyboard, the bottom row Z, X, C, V, B, N, M and comma plays the white notes starting from the lowest key, and S, D, G, H and J play the black notes between them. The top row Q, W, E, R, T, Y, U and I plays the white notes of the next octave up, with the number keys 2, 3, 5, 6 and 7 as the black keys. Each key shows its letter, and every C is labelled with its octave if the names option is on.
A worked example
Leave the octave at 3, so Z plays C3, and press Sample. The page plays a 14-note melody, 0.38 seconds apart, whose notes are C, C, G, G, A, A, G, F, F, E, E, D, D, C, which is the first line of the well-known nursery tune, moving through the keys. To play it yourself, press the keys in that order. Press Octave up and the same melody sounds an octave higher, from C4, and the keys light up as they are played.
Sounds
Soft uses a triangle wave, which is mellow and close to a flute. Pure is a sine wave, with a single frequency. Chiptune is a square wave, hollow and reedy as in old computer games. Bright is a sawtooth, the fullest and buzziest. Each note is one oscillator; the page does not play recordings of a real piano, so it is for finding notes and tunes more than for performing.
Release and sustain
Release sets how long a note fades after the key is let go, from 0.05 to 2 seconds. A short release is clean and detached; a long one blurs notes together, rather like a pedal. The sustain option keeps notes ringing for about a second after release, so you can play slow chords with a light touch. Volume starts at 40 percent, and the slider is squared internally so the lower half is gentle.
Edge cases
Browsers need a first click or key press before they allow sound. Holding down more keys than your keyboard can report is blocked by the hardware, and the result varies by model. The octave buttons stop at 0 and 6, and the lowest key shown depends on the octave. Keys with Ctrl, Alt or the system key held down are ignored so shortcuts keep working, and typing in a field does not play notes.
Limits
There is no recording, no velocity or touch sensitivity, and no MIDI-keyboard input. The sound is a simple synthesizer. Nothing leaves your device.
Related tools
- Note Frequency Chart shows the frequency of each key.
- Circle of Fifths explains which notes belong together in a key.
- MIDI File Player plays a MIDI file with a synthesizer.
- Online Tuner checks the pitch of a real instrument.
Checked against the current version of the Virtual Piano on .

