refactor keyboard input and add mouse input