Answers for "pygame key hold"

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

pygame keys keep pressing

while not done:
    for e in event.get():
        if e.type == KEYDOWN:
            keys = key.get_pressed()
            if e.type == QUIT or keys[K_ESCAPE]:
                done = True
            if keys[K_DOWN]:
                print "DOWN"
Posted by: Guest on December-21-2020

Python Answers by Framework

Browse Popular Code Answers by Language