title: How to use Keyup in pygame
body: <p>I'm an extremely new programmer, so could you please explain everything that you do in depth.</p>
  
  <p>here's my code for testing(please note that the indents are all wrong):</p>
  
  <pre class="lang-py prettyprint-override"><code>import pygame
  
  pygame.init()
  
  win = pygame.display.set_mode((500,500))
  pygame.display.set_caption("First Game")
  
  x = 50
  y = 50
  width = 40
  height = 60
  vel = 5
  
  run = True
  
  while run:
      pygame.time.delay(100)
  
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              run = False
      for event in pygame.event.get():
          if event.type == pygame.KEYUP:
              if event.key == pygame.K_UP:
                  y -= vel
              if event.key == pygame.K_DOWN:
                  y += vel
              if event.key == pygame.K_RIGHT:
                  x += vel
              if event.key == pygame.K_LEFT:
                  x -= vel
      win.fill((0,0,0))
      pygame.draw.rect(win, (255,0,0), (x, y, width, height))   
      pygame.display.update() 
  
  pygame.quit()
  </code></pre>