So, this is really mostly about PTYs, not std input: key presses in a running process aren't usually standard input!
So, what you need is a pseudo-TTY emulator that will both deal with inputs as well keep a timer for how long nothing has happened on screen.
tmux can do that. Install tmux, and create a tmux.conf in ~/.config/tmux, containing (at least) the following (60 s screensaver delay)
set -g lock-command "the program you want to be screensaver. It has to quit when a key is pressed, but that's your problem to implement" set -g lock-after-time 60
You can then run your "main" program as
tmux new yourprogram
(or just use tmux as usual, see numerous tmux tutorials)
Using reptyr you can migrate an already program to a tmux session; haven't tried whether the inactivity detection still works.
/proc/<pid>/fd/*or a device like/dev/pts/1. I'd very much prefer that this does not require root.