The earliest designs of keyboards were based heavily on the notes used in Gregorian chant (the seven diatonic notes plus B-flat) and as such would often include B at the rightmost.

This allows close to uniform spacing of 12 keys per octave while maintaining uniformity of seven "natural" keys per octave.Over the last three hundred years, the octave span distance found on historical keyboard instruments (organs, virginals, clavichords, harpsichords, and pianos) has ranged from as little as 125 mm to as much as 170 mm.Modern piano keyboards ordinarily have an octave span of 164–165 mm; resulting in the width of black keys averaging 13.7 mm and white keys about 23.5 mm wide at the base, disregarding space between keys.Depressing a key on the keyboard causes the instrument to produce sounds, either by mechanically striking a string or tine (piano, electric piano, clavichord), plucking a string (harpsichord), causing air to flow through a pipe (organ), striking a bell (carillon), or, on electric and electronic keyboards, completing a circuit (Hammond organ, digital piano, synthesizer).Since the most commonly encountered keyboard instrument is the piano, the keyboard layout is often referred to as the "piano keyboard".