← Wiki · Component

Key switch and hot-swap socket

Mechanical keyboard switches (MX, Choc, Alps) wired in a row/column matrix with one diode per key. Hot-swap sockets let you change switches without soldering.

What it does#

Electrically a key switch is just a button. The interesting part is how many there are: instead of one GPIO per key, keyboards use a matrix of rows and columns. A 60 % board (61 keys) needs 5 rows × 14 columns = 19 pins. The controller drives one column at a time and reads the rows.

The diode#

Every key gets its own small diode in series. Without them, three keys pressed in a rectangle make the fourth corner look pressed (“ghosting”).

Example circuit: Two hot-swap MX keys on ROW0. Column → switch → diode anode; cathode → row (COL2ROW). The header stands for the controller.
Two hot-swap MX keys on ROW0. Column → switch → diode anode; cathode → row (COL2ROW). The header stands for the controller. Open the key_switch_row example from this page in PCB Canvas: “Insert into my schematic”.

Switch families#

Family Footprint in the catalog Notes
Cherry MX and clones MX soldered, MX hot-swap 3-pin or 5-pin (2 extra plastic pegs)
MX/Alps hybrid one footprint takes either
Kailh Choc v1 / v2 soldered or hot-swap low profile; v1 and v2 keycaps differ
Alps / Matias soldered

Hot-swap sockets#

A Kailh-style socket is soldered to the back of the PCB; the switch’s pins push into it. Great for trying switches. The catalog’s MX socket is the HanElectricity CPG151101S11-16 (C41430893) on the Kailh footprint, because Kailh’s own socket was out of stock at JLCPCB; Choc sockets are not stocked there at all, so you solder those yourself.

Pitfalls#

  • Diode direction must match the firmware (COL2ROW or ROW2COL).
  • Hot-swap sockets need a plate or the switches pull the sockets off the board when you remove keycaps.
  • Choc and MX spacing differ (18 × 17 mm vs 19.05 mm); the KLE import uses the switch you pick.

Footprint#

Switches themselves are hand-soldered (JLCPCB does not place them). Diodes and sockets can be assembled.