keyboard controller refactoring