A keyboard switch is a small, mechanical device that connects keys to the electronic circuit board inside the keyboard. The purpose of the switch is to detect when a key has been pressed and to complete an electrical circuit that registers that keystroke on the computer.
The switches on a keyboard come in different colors, shapes, and sizes. This is because different switches are designed for different purposes.