I want to pause and continue threads if a certain key is pressed. I tried: if q is pressed it will remove(change to 0) the "time.sleep(99999)" but it didnt work can anyone help me?
import keyboard
from threading import Thread
from time import sleep
Thread1 = True
Thread2 = True
class main():
def test1():
if keyboard.is_pressed("q"): #if keyboard is pressed q it will reomve the sleep
time = 0
time = 99999
while Thread1 == True:
print("Thread1")
sleep(time)
def test2():
while Thread2 == True:
print("Thread2")
sleep(1)
Thread(target=test1).start()
Thread(target=test2).start()
main()