0

I am iterating through files in a folder, and for each file I want to be able to press either "y" or "n" on the keyboard (not in the terminal, just listen to the keystroke event) regardless of the focus window and do something with that information. I.e. for each iteration, I don't want to have to move my mouse to the terminal, click it, press "y" and press enter. Just n or y instantly and move to the next iteration. Is this possible and if so how do I do it? It is on linux if it matters.

1 Answers1

0

you need some kind of keyboard event listener
i think Tkinter has it
otherwise use some other python library
1 example: Detecting a keypress in python while in the background