title: Stop game character from moving after paused game
body: <p>I have this 2D platformer game in PyGame where a character moves left, right and up (jump). I recently implemented a function to pause the game, which works great.</p>
  <p>However since the code stops the character on <code>pygame.KEYUP</code> then if the user lets off the side-moving keys (A for left, D for right) AFTER they have paused the game then after resuming the character will be stuck running since it never got the KEYUP event.</p>
  <p>Any ideas that makes the character stop X-axis movement after pause? Thankful for any help!</p>
  <p>Pause function:</p>
  <pre><code>def game_pause:
      pause = True
      while pause == True:
          pygame.init()
          for event in pygame.event.get():
              if event.type == pygame.QUIT:
                  pygame.quit()
              if event.type == pygame.KEYDOWN:
                  if event.key == pygame.K_RETURN:
                      pause = False
  </code></pre>
  <p>Main
  loop:</p>
  <pre><code>while not done:
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              done = True
          
          #---Key presses---
          if event.type == pygame.KEYDOWN:
              if event.key == pygame.K_a:
                  player.go_left()
              elif event.key == pygame.K_d:
                  player.go_right()
              elif event.key == pygame.K_SPACE:
                  player.jump()
              elif event.key == pygame.K_RETURN:
                  game_pause()
  
          elif event.type == pygame.KEYUP:
              if event.key == pygame.K_a and player.change_x &lt; 0:
                  player.stop()
              elif event.key == pygame.K_d and player.change_x &gt; 0:
                  player.stop()
  </code></pre>
  <p>Functions that moves the player-class:</p>
  <pre><code>    def go_left(self):
          self.change_x = -5
      def go_right(self):
          self.change_x = 5
      def stop(self):
          self.change_x = 0
  </code></pre>