need help to end loop using keyboard shortcut
### Hi guys, I need help to end the run_porgram() loop using a keyboard shortcut since my program is running in another window other than terminal using Ctrl+C is not working, I can set how many times it should run but sometimes I need to stop it earlier. ### import time import pyautogui, sys from time import sleep def search_cycle_increase(): pyautogui.click(1078, 799) # search sleep(0.8) pyautogui.click(1183, 743) # buy now sleep(0.12) pyautogui.click(724, 530) # ok sleep(0.12) pyautogui.click(123, 215) # back sleep(0.12) pyautogui.press('k') sleep(0.12) def search_cycle_decrease(): pyautogui.click(1078, 799) # search sleep(0.8) pyautogui.click(1183, 743) # buy now sleep(0.12) pyautogui.click(724, 530) # ok sleep(0.12) pyautogui.click(123, 215) # back sleep(0.12) pyautogui.press('l') sleep(0.12) def cycle_complete(): for i in range(0,5): search_cycle_increase() for i in range(0,5): search_cycle_decrease() def run_program(): run = input("How many times you want to run the program? ") x = 0 while x<=int(run): sleep(3) x+=1 cycle_complete() run_program()