applying refactoring for keyboard movements