Answer the question
In order to leave comments, you need to log in
How to stop entering values on pressing CTRL?
import keyboard
Array = []
while not(keyboard.is_pressed('ctrl')):
Array += input()
print(Array)
Answer the question
In order to leave comments, you need to log in
import signal
import time
class SigHandler:
stop = False
def __init__(self):
signal.signal(signal.SIGINT, self.exit)
signal.signal(signal.SIGTERM, self.exit)
def exit(self, *args):
print(signal.strsignal(args[0]))
self.stop = True
if __name__ == '__main__':
Array = []
signal_handler = SigHandler()
while not signal_handler.stop:
Array += input('Input value: ')
print(Array)
time.sleep(0.5)
print("Exit")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question