pause function now works smoothly. used the keyup event on the space key