refactored out keyboard handling to a module