Hi, I’m an embedded developer and trying to write some python software for a personal project (A bot for an idle game).

One concept I’m struggling with is asynchronous behavior and interrupts on desktop systems. I’m not really finding any good resources. I’m hoping one of you guys can explain this in a way that I get it or provide me some good resources to read.

What I want to do is pretty simple. I want to have a super loop around my software which runs until a condition is met (A specific key is pressed). I’d rather not use polling, requesting an input will block the software and require user input each loop. I’ve tried reading the keyboard state directly but the packages I used either didn’t find my keyboard or required root access.

My preferred attempt would have been to register something like an interrupt handler which is called when a keyboard event is detected. The general suggestion on the internet for interrupts in python is the signal package. This however seems to only be for dealing with exceptions, not general interrupts.

Are interrupts for general events like I/O even a thing on desktops? And if so, how would I go about interacting with them from my code?