Function is triggered after I release the key for some more time.
If you hold down 'E' for 5 seconds, the 'E' key will be pressed ~10 times during this time, then the function will be played all ~10 times, even if the key has already been released
How to make the function work only if the E key is held down, and after releasing the function stops?
import keyboard # https://github.com/boppreh/keyboard#keyboard.on_press_key
import mouse # https://github.com/boppreh/mouse#mouse.is_pressed
from time import sleep
def ButtonTest(KBEvent):
print("Key W: ", keyboard.is_pressed('w'))
print("Right Mouse: ", mouse.is_pressed(button='right'))
keyboard.press('ctrl')
sleep(1)
keyboard.release('ctrl')
keyboard.on_press_key('e', ButtonTest)
keyboard.wait()