import pygame import sys pygame.init() screen = pygame.display.set_mode((400,300)) surface = pygame.surface((50, 50)) surface.fill((0,255,0)) pos = [175, 125] while True: events = pygame.event.get() for event in pygame.event.get(): if event.type == quit: pygame.quit() sys.exit() pygame.display.update() if event.type == pygame.KEYDOWN: if event.key == pygame.K_RIGHT: pos[0] += 20 screen.blit(surface, pos) pygame.display.update()