For the keyboard itself:

1.  Undo the screws from the bottom of the case.
2.  Lift the top of the case gently off.
3.  Disconnect the ribbon cables from the keyboard (CAREFUL fragile)
4.  Slide out the keyboard.
5.  Insert the new one and attach the ribbon cables.
6.  Clip the case back together and do up the screws

For the membrane:

1.  Prise the top off the case - early models were clipped, later ones glued
2.  Gently pull the keyboard membrane and its support out of the case.
3.  Blow out the years of accumulated grot.
4.  Slide the new keyboard and membrane back in.
5.  Clip / tack the case back together.



There is a much longer guide <a href="http://www.dataserve-retro.co.uk/contents/en-uk/d31.html">here</a> with pictures.