Key switches provide the interface between the mechanical and the electrical portions of the piano.
Rubber Membrane Keyswitches
The vast majority of commercial keyboards use rubber membrane key-switches. While these are one of the most inexpensive technologies to mass-produce since the switches for many keys are effectively stamped into one part, they have a limited lifetime, and are typically one of the first things to fail in commercial keyboards.
Optical Keyswitches
LED/Photodiode pairs are more reliable than rubber keyswitches, and are already seem to be the for retrofitting acoustic pianos with digital technology.
Conducting Spring Switch
Magnetic Keyswitches
Magnetic switches (hall effect sensors). Hall effect sensors are four terminal devices. If put a current across the chip in one direction, an applied magnetic field will alter the trajectory of the moving electrons, resulting in a measurable voltage potential across the other two pins. While these can be as cheap as optical sensors, it is a lot harder to prevent magnetic interference between keys than it is to prevent optical interference.
Capacitive Keyswitches
The major drawback of capacitive switches is that they require a rather high voltage bus in order to have good noise immunity.