Python Forum

Full Version: How many times was the button pressed in pyglet
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!