Update keyboard-handling code.