Code for the keypad controller.