title: Double jump issue pygame with get key presses
body: <p>I have created double jump in a few games now, but always in key events in game loop. This is not working for me here now I have put it into 'get key presses' in player class. I have created the boolean to show '1' when in air, and then reset it back to 0 when jumped while its on '1'. but then when I jump it instantly goes back to 0 so I can infinitely jump.</p>
  <pre><code>#player movement
      self.movement = pygame.math.Vector2()
      self.speed = speed
      self.gravity = 1
      self.collision_sprites = collision_sprites
      self.grounded = False
      self.jump_counter = 0
  
  def input(self):
      keys = pygame.key.get_pressed()
  
      if keys[pygame.K_d]:
          self.movement.x = 1
      elif keys[pygame.K_a]:
          self.movement.x = -1
      else:
          self.movement.x = 0
  
      if keys[pygame.K_w] and self.grounded == True:
          self.movement.y = -JUMP_SPEED
          self.jump_counter = 1
  
      if keys[pygame.K_w] and self.jump_counter == 1:
          self.movement.y = -JUMP_SPEED
  
          self.jump_counter = 0
  
      print(self.jump_counter)
          
  
  def x_collisions(self):
      for sprite in self.collision_sprites.sprites():
          if sprite.rect.colliderect(self.rect):
              if self.movement.x &lt; 0:
                  self.rect.left = sprite.rect.right
              if self.movement.x &gt; 0:
                  self.rect.right = sprite.rect.left
  
  def y_collisions(self):
      for sprite in self.collision_sprites.sprites():
          if sprite.rect.colliderect(self.rect):
              if self.movement.y &gt; 0:
                  self.rect.bottom = sprite.rect.top
                  self.grounded = True
                  self.jump_counter = 0
                  self.movement.y = 0
              if self.movement.y &lt; 0:
                  self.rect.top = sprite.rect.bottom
                  self.movement.y = 0
  
      if self.grounded == True and self.movement.y != 0:
          self.grounded = False
  
  
  def apply_gravity(self):
      self.movement.y += self.gravity
      self.rect.y += self.movement.y
      if self.movement.y &gt; TERMINAL_VELOCITY:
          self.movement.y = TERMINAL_VELOCITY
  
  def update(self):
      self.input()
      self.rect.x += self.movement.x * self.speed
      self.x_collisions()
      self.apply_gravity()
      self.y_collisions()
  </code></pre>