import subprocess import keyboard #async def subp(): proc = subprocess.Popen("node main") #asyncio.run(subp()) while True: try: if keyboard.is_pressed('q'): proc.kill() exit() except: print("q") proc.kill() exit()