Refactored the keyboard input handler following the JS OOP pattern