Hold down right click python with hotkey start and stop



import threading
import time
import pyautogui
import keyboard


event = threading.Event()

def start():
    event.set()		
    pyautogui.mouseDown(button='right')
keyboard.add_hotkey("space", start)

def stop():
    event.set()		
    pyautogui.click(button='right')
keyboard.add_hotkey("ctrl", stop)

while True:
    
    time.sleep(1)