title: How can you disable key press and hold in pygame?
body: <p>I am struggling how I can make it so that when a key is pressed in Pygame, you aren't able to keep on holding the key.
  I am working on player jumps, but it doesn't work unless the key is only pressed once.
  Here is my keypress code:</p>
  <pre><code>keys = pygame.key.get_pressed()
  if keys[pygame.K_UP] and not self.jumping:
      self.jumping = True
  </code></pre>
  <p>And here is my jumping method (which also includes gravity)</p>
  <pre><code>def gravity(self):
          # if the player isn't jumping
          if not self.jumping:
              # set acceleration constant and accelerate
              self.accel_y = PLAYER_ACCELERATION
              self.y_change += self.accel_y
  
              # terminal velocity
              if abs(self.y_change) &gt;= PLAYER_MAX_SPEED_Y:
                  # set the y change to the max speed
                  self.y_change = PLAYER_MAX_SPEED_Y
  
              self.y += self.y_change
  
          else: # jumping
              self.accel_y = -PLAYER_ACCELERATION_JUMPING
              self.y_change += self.accel_y
  
              if abs(self.y_change) &gt;= PLAYER_MAX_SPEED_JUMPING:
                  self.jumping = False
  
              self.y += self.y_change
  
              print(self.y_change)
  </code></pre>
  <p>The player can just keep on holding the up arrow key, and the player will fly - which is not good. I would like it so that you can only press once, and then <code>self.jumping</code> is set to <code>False</code> when it has reached it's top speed (which I have already implemented)</p>