python - How do I count everytime I press a key down? -
i want count everytime hit left button code looks this
import pyautogui import pygame event in pygame.event.get(): if event.type == pygame.keydown: if event.key == pygame.k_left: print (sequentially amount of times i've hit left)
just store data in variable , increment it:
import pyautogui import pygame number_of_presses = 0 event in pygame.event.get(): if event.type == pygame.keydown: if event.key == pygame.k_left: number_of_presses += 1 print (number_of_presses)
should work great.
Comments
Post a Comment