Refactoring: separating concerns of keyboard control