As early as the 8th century, musical instruments have had keys, though the keyed instrument Emperor Constantine sent to King Pepin of France was probably nothing like the keyboard instruments of today.
In the early part of the 11th century, Guido of Arezzo, a Benedictine monk who is regarded to be the inventor of modern musical notation (the staff) and the ut-re-mi (do, re, mi name for tones) devised a way to attach a keyboard to a stringed instrument.
One of the earlier keyboard instruments was the clavichord, which at first had only twenty keys.
After the 15th century almost all the key-stringed instruments used the chromatic scale, as we find it in modern pianos. Keyboard size varied from instrument to instrument.
In the 18th century, a piano maker in Vienna built a concave-formed keyboard, convinced it would better serve the tendency of the human arm to move in a semicircle.
A piano maker in the 19th century designed a keyboard on which the semitones (our black keys) were the same color as the full tones, and were not raised. Thus, the keyboard we know today is the result of experimentation through the ages. As a pianist, I am grateful to have raised black keys and the full 88-key keyboard of today.
For further reading go to http://www.pianoworld.com/