Implemented key presses, cleaned up code