Sinclair ZX81
The keyboard on the ZX81 is made from a keyboard membrane (in common with most keyboards today). The membrane consists of two layers of plastic which have electrical tracks running through them, which are connected to the motherboard by the means of two long keyboard tails. When you press a key, you press the two layers together, completing the circuit and therefore allowing the ROM to detect which key has been pressed.

With age, the plastic layers become brittle and crack, damaging the tracks.

Replacing a keyboard membrane is easy.

You basically just need to undo the screws on the bottom of the case and ease the two case halves apart. You will need to remove the keyboard membrane tails from the two sockets on the motherboard (and check that no bits are left inside the sockets).

Now you can take the old keyboard off the top of the case - it is glued down, so you can either soak it in hot water, or use a hairdryer to melt the glue.

Just replace it with the new keyboard membrane (push the two tails through the hole in the top of the case, remove the adhesive backing and stick down).

Now push each membrane into the socket on the motherboard, put the two case halves back together and re-tighten the screws.

Sinclair ZX80
This has a different procedure, as the keyboard is actually made up of three parts.
a) The top foil layer which has the actually keyboard set into it. The back of this is made from a type of foil which conducts electricity.
b) A middle layer (this is already attached to the top layer on new replacement keyboards) - this contains holes underneath each key, revealing the foil backing.
c) The motherboard layer. This has spiral solder tracks on the motherboard, which form each key. Each spiral is made up of two tracks which do not touch. When you press down a key, the foil backing moves through the hole in the middle layer and completes the circuit between the two spiral tracks, so that the ROM can detect which key is pressed.

Replacing these keyboards is again quite simple. The hardest part is getting the ZX80 case apart without damaging the plastic rivets which hold the two case halves together.

Once you have separated the case, you will need to peel off the old keyboard layer from the motherboard.

Then remove the backing from the new keyboard layer, and apply the new keyboard to the motherboard, ensuing that is is matched up correctly.