title: how can make my object stop?
body: <p>I can make my object stop. Once I press w,a,s or d it moves but doesnt stop. When I press one of the directions it moves but it doesnt stop. I need it to stop when I release the key. All types of help will be appreciated. Heres my code:</p>
  
  <pre><code>while (running == 1):
      screen.fill(white)
      for event in pygame.event.get():
          if (event.type == pygame.QUIT):
              running = 0
          elif (event.type == pygame.KEYDOWN):
              if (event.key == pygame.K_d):
                  dir = "R"
              elif (event.key == pygame.K_a):
                  dir = "L"
              elif (event.key == pygame.K_s):
                  dir = "D"
              elif (event.key == pygame.K_w):
                  dir = "U"
              elif (event.key == pygame.K_ESCAPE): 
                  sys.exit(0)
              elif (event.key == pygame.K_SPACE):
                  shot=True
                  xbul=xgun
                  ybul=ygun
              #if key[K_SPACE]:
                  #shot = True
  
  
      #OBJECT'S MOVEMENTS
      if (dir == "R" and xgun&lt;595):
          xgun = xgun + 3
          pygame.event.wait
      elif (dir == "L" and xgun&gt;0):
          xgun = xgun - 3
          pygame.event.wait
      elif (dir == "D" and ygun&lt;460):
          ygun = ygun + 3
          pygame.event.wait
      elif (dir == "U" and ygun&gt;0):
          ygun = ygun - 3
  
      screen.blit(gun, (xgun,ygun))
      #PROJECTILE MOTION
      #key = pygame.key.get_pressed()
  
      if shot == True:
          xbul = xbul + 3
          screen.blit(bullet, (xbul, ybul))
  
      if xbul&gt;600:
          shot=False
  
      pygame.display.flip()
      time.sleep(0.01)
  </code></pre>