Code cleanup in keyboardInput()