state = pygame.key.get_pressed() if state[pygame.K_SPACE]:

Read more of this post