I have the following script, which detects keyboard inputs and prints the pressed keys:
import msvcrt
while True:
if msvcrt.kbhit():
key = msvcrt.getch()
print("Key is {}".format(key))
The problem is that I can only type/enter characters into my terminal window, where the script output is. In other words, if I open a new program/window and start typing there, the script is not detecting the input. How do I solve this?