I am trying to detect a long press event and cancel it if the button is released before the timer times out, however the timer never gets cancelled and fires if it is a short press or a long one:
from threading import Thread
but_down = Timer(1.5,long_press)
if(but=='down'):
but_down.start()
else:
but_down.cancel()
def long_press():
print('long press')