After calling 'add_key_down_handler(argmt)' how could I set it up so that when one of the keys is pressed the handler stops running? (Python)

67 views Asked by At

For instance in this code:

def check(event):
     if event.key == "a":
          function()

add_key_down_handler(check)

If the key "a" is clicked again after this, function() should not run.


The way I tried to solve this was to do the following:

def check(event):
     if event.key == "a":
          function()
          remove_key_down_handler(check)

add_key_down_handler(check)
0

There are 0 answers