import pygame keys = pygame.key.get_pressed() if keys[pygame.K_LEFT]: x -= 1 if keys[pygame.K_RIGHT]: x += 1