0

I have this code:

from os import system
import keyboard as ky
def process1():
    print("Process 1")
    a = input("Enter a Character (Process 1): ")
    print(a, "in process 1")

def process2():
    print("Process 2")
    b = input("Enter a Character (Process 2): ")
    print(b, "in process 2")

def redirect():
    system('cls')
    process2()
ky.add_hotkey('ctrl+h', redirect)
process1()
ky.wait()

I want the program to stop the process 1 when ctrl + h is pressed and then start with process 2. But I still have the input statement of process one remains there

  • 1
    I bet you're a beginner and it'll be hard to understand how concurrent programming works – Alexey S. Larionov Jun 15 '21 at 08:13
  • You need something like a _KeyListner_. Check out [here](https://stackoverflow.com/questions/11918999/key-listeners-in-python) to see if you can find something. – ARK1375 Jun 15 '21 at 08:15

0 Answers0