Keyboard code cleanup