Underneath each key is a switch. When the key is pressed, the switch closes. Three types of switches are used in keyboards:
These keyboards use standard spring-loaded momentary-on switches, most of which are made by Alps Electric. Pressing a key compresses a spring and causes a plunger on the bottom of the key to make physical contact to close the connection. When the key is released, the spring forces it back into rest position. These keyboards provide the clacky feel typical of the original IBM Selectric and PC keyboards, are quite durable, and are usually relatively expensive ($75 to $125).
These keyboards are unique in that pressing a key does not make electrical contact to complete the circuit. Instead, movement of the plunger on the bottom of a key alters the state of a capacitive circuit, which the keyboard controller recognizes as a key press. Keyboards with capacitive switches provide clacky feedback, are even more durable than mechanical keyboards, and are quite expensive ($100 to $200). As far as we know, only IBM and Lexmark have produced such keyboards.
Most current keyboards use membrane switches. Unlike mechanical and capacitive keyboards, which use discrete physical switches for each key and are correspondingly expensive to produce, a membrane keyboard combines all key switches into one unit comprising three membrane layers. The bottom layer has printed conductive traces that correspond to the individual key switches. The middle layer is a spacer, with holes that expose each underlying switch. The top layer is an array of rubber domes, against each of which the bottom of a key impinges. When a key is pressed, it forces the conductive bottom of the rubber dome through the spacing layer and into contact with the switch traces on the bottom layer, completing the circuit. When the key is released, the rubber dome forces it back into rest position. Early membrane keyboards were known for mushy feel and lack of tactile feedback. Current production models are better in that respect, so much so that it is often difficult to tell by feel alone whether you are using a mechanical keyboard or a modern membrane keyboard. Membrane keyboards are also inexpensive ($15 to $50), and nearly as durable and reliable as the best of the mechanical and capacitive keyboards.
Switch type as it related to durability was an important factor when keyboards cost $200. With high-quality membrane keyboards now selling for $25 or so, that distinction is much less important.