Answers for "pygame key events"

3

pygame keydown

for event in pygame.event.get():
	if event.type == pygame.KEYDOWN:
    	return True
Posted by: Guest on June-19-2020
1

key pressed pygame

letters = {x: pygame.key.key_code(x) for x in "abcdefghijklmnopqrstuvwxyz"}

touche = pygame.key.get-pressed()

for (l, value) in letters.items() :
  if touche[value] :
    print(f"The letter {l} has been pressed ;)")
Posted by: Guest on March-28-2021
0

keyboard events pygame

for event in pygame.event.get():
    if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_q:
            exit(0)
        elif event.key == pygame.K_LEFT:
            print("You pressed LEFT")
        elif event.key == pygame.K_RIGHT:
            print("You pressed RIGHT")
Posted by: Guest on June-01-2021

Python Answers by Framework

Browse Popular Code Answers by Language