Python Forum
How many times was the button pressed in pyglet
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How many times was the button pressed in pyglet
#1
Hi,
I have a following issue. I need to count how many times did I press any button on my keyboard. See following example:

import pyglet

@window.event
def on_key_press( symbol, mod):
    count = 0

    if symbol == pyglet.window.key.NUM_1:
        count += 1
        print(count) 
In other words I need two helps. Firstly, how to write "any key" (not only 1 as I have now in pyglet.window.key.NUM_1). Secondly, How to count, because now I always set count = 1, so my output is always 1.

Thanks a lot!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Playing mp3 with pyglet constantin01 3 5,505 Dec-17-2021, 01:14 PM
Last Post: Legumen
  pyglet problem deansenecal 1 1,950 Feb-15-2021, 11:15 PM
Last Post: Larz60+
  Getting button pressed number Moris526 4 2,440 Dec-14-2020, 01:41 AM
Last Post: Moris526
  run different functions each time the same button is pressed? User3000 6 3,318 Jul-31-2020, 11:11 PM
Last Post: User3000
  Running Ajax multiple times on button click? CaptainCsaba 1 2,117 Mar-11-2020, 02:17 PM
Last Post: CaptainCsaba
  Terminate a process when hotkey is pressed 66Gramms 0 2,250 Dec-24-2019, 06:41 PM
Last Post: 66Gramms
  Advance program when certain keys are pressed? Chrislw324 2 2,344 May-19-2019, 07:13 PM
Last Post: woooee
  Count to movement according to the time pressed button noartist 1 2,520 Feb-27-2019, 01:33 PM
Last Post: noartist
  What key pressed? ian 2 4,988 Jul-29-2018, 02:30 AM
Last Post: snippsat
  Pyglet installation problems LostinPy 3 5,569 Feb-07-2018, 08:47 PM
Last Post: LostinPy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020