dpressed = 0
def on_press(key):
if key == ('d'):
global dpressed
dpressed+=1
logging.info("D: %s" % dpressed)
When I run this code and press d, nothing happens, which I suspect is because the key needs to be called something else when checked. Does someone know what it should be?
You need to format the key to char format else it won't be equeal to the specific character.
Try
if key.char == ('d'):
Full code being:
dpressed = 0
def on_press(key):
if key.char == ('d'):
global dpressed
dpressed+=1
logging.info("D: %s" % dpressed)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With