1import pygame
2events = pygame.event.get()
3for event in events:
4 if event.type == pygame.KEYDOWN:
5 if event.key == pygame.K_LEFT:
6 location -= 1
7 if event.key == pygame.K_RIGHT:
8 location += 1
9
1if pygame.mouse.get_pressed()[0]:
2 # do something when the left mouse button is pressed
3keys = pygame.key.get_pressed()
4if keys[pygame.K_a]:
5 # do something when the a key is pressed
1letters = {x: pygame.key.key_code(x) for x in "abcdefghijklmnopqrstuvwxyz"}
2
3touche = pygame.key.get-pressed()
4
5for (l, value) in letters.items() :
6 if touche[value] :
7 print(f"The letter {l} has been pressed ;)")