Keyboard instruments are those in which sounds are triggered and controlled by a set of keys.
To understand how they work, imagine the key as a seesaw. When its outer end is touched and lowered, the other immediately rises and triggers the mechanism that produces the sound. There are different types of mechanisms that originate the sounds through the keys, and therefore there are also different types of instruments such as the piano, the harpsichord and the organ, among others.
The first keyboards appeared in the 3rd century BC. C., with the hydraulic organs, in the Greco-Roman era, but they only gained importance in the western civilization.
Ancient instruments had both different keyboards and techniques to play. They had only the keys that today we call "white" and the musician did not use the fingers, but the wrists. The "black" keys gradually emerged from 12th century, and only at beggining 15th century the keyboard became like we know nowadays.