Refactor KeyListener