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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -