I worked on this for nearly 6 hours. Although your suggestion had a lot of merit, implementing it is very difficult, and I was not comfortable with the reliability of the result.
The problem is this: There are too many code paths to identify and get to a complete set of idle-breaking (I like that term by the way). The principle issue is the “type a key” action, which are sprinkled liberally throughout my code. Why?
Keys are the way to navigate spaces. It’s not just the hot key to get to the first space on screen 1 or the first space on screen 2. It’s also the way one scrolls among spaces.
You ask what the purpose is. I’ve written a very sophisticated wallpaper management subsystem during the pandemic. Magazines, museums, newspapers, and more have released a lot of high quality jpegs during the pandemic, and I have a large collection of them. No, I don’t distributed them, but the software to manage them is posted in the KM Forum. From there, It was easy to develop a screensaver.
I also wrote a macro to manually turn off the screen to save energy.
The problem was when I combined the two I started running into a lot of complexity. The Idle trigger was insufficient, since IDLE() was being reset by the screensaver. I did work out a system that works that looked at USB device keys, and window change events, and then wrote a system to trim the logs, since they were getting pretty large (type a key, type a left or right shift, left or right option, page up and down, etc. This worked but as you might imagine it generated too many events, and I was concerned about the overhead.
So, I backed out of it for now. If I want to turn off the screen, I have a hot key trigger. It will do for now.
Again, thanks for trying to help.