Answer the question
In order to leave comments, you need to log in
How to stop code from executing code by successively pressing ctrl + c keys without calling KeyboardInterrupt?
import keyboard
import time
def waiting():
curtime = time.perf_counter()
while (time.perf_counter() - curtime) <= 2:
keyboard.add_hotkey('Ctrl + c', exit())
cycle()
def cycle():
while True:
try:
keyboard.add_hotkey('Ctrl + c', lambda: print('Hello'))
except KeyboardInterrupt:
waiting()
cycle()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question