pygame get if button is released

for event in pygame.event.get() :
  if event.type == pygame.KEYDOWN :
    if event.key == pygame.K_SPACE :
      print "Space bar pressed down."

Here is what the above code is Doing:
1. It’s creating a for loop that iterates through all of the events in the event queue.
2. It’s checking to see if the event type is equal to pygame.KEYDOWN.
3. It’s checking to see if the key that was pressed is equal to pygame.K_SPACE.
4. If all of the above conditions are met, it prints “Space bar pressed down.”

You can also check for multiple keys at the same time. For example, if you wanted to check if the space bar and the left arrow key were pressed at the same time, you could do this:

for event in pygame.event.get() :
if event.type == pygame.KEYDOWN :
if event.key == pygame.K_SPACE and event.key == pygame.K_LEFT :
print “Space bar and left arrow key pressed down.”