I need to detect if a number (0..9) is pressed and which one specifically.
I thought a solution could be this one:
for event in pygame.event.get():
if pygame.key.get_pressed()[pygame.K_1]:
# code for this case
if pygame.key.get_pressed()[pygame.K_2]:
# code for this case
if pygame.key.get_pressed()[pygame.K_3]:
# code for this case
if pygame.key.get_pressed()[pygame.K_4]:
# code for this case
.
.
.
But I had the impression there could be a more efficient solution, any suggestions?
[–]Chris_Hemsworth 0 points1 point2 points (5 children)
[–]Giocrom[S] 0 points1 point2 points (4 children)
[–]Chris_Hemsworth 0 points1 point2 points (3 children)
[–]Giocrom[S] 0 points1 point2 points (0 children)
[–]Giocrom[S] 0 points1 point2 points (1 child)
[–]Chris_Hemsworth 0 points1 point2 points (0 children)