You can use pygame.key.get_pressed to do that.
example:
while running: keys = pygame.key.get_pressed() #checking pressed keys if keys[pygame.K_UP]: y1 -= 1 if keys[pygame.K_DOWN]: y1 += 1
2.1m questions
2.1m answers
60 comments
57.0k users