A diode is a component that allows current flow in one direction only.
Diodes are used on contact-switched keyboards to provide N-key rollover support. They also provide the electrical basis for light-emitting diodes, which amongst many other things provide backlighting for keyboards.
Diodes on the Zenith Supersport SX keyboard
Cherry MX Black switches with diodes fitted
Surface-mounted diodes on a KBC Poker II PCB