1running = True
2while running:
3 for event in pygame.event.get():
4 if event.type == pygame.QUIT:
5 pygame.quit(); sys.exit()
6 running = False
7
8 if event.type == pygame.KEYDOWN:
9 if event.key == pygame.K_LEFT:
10 print('left')
11 if event.key == pygame.K_RIGHT:
12 print('right')
13 if event.key == pygame.K_UP:
14 print('up')
15 if event.key == pygame.K_DOWN:
16 print('down')
17
18