Suppose that I have an Emacs session running, and that I step away from my computer for, say, 20 minutes. Upon returning to my Emacs session, at some point I will press some key while the Emacs window has the focus. This would be an example of the sort of event I'm calling first-keypress-in-a-while
1.
I'm looking for a way to have Emacs automatically run some code whenever such an event happens. IOW, I'm looking for something like a first-keypress-in-a-while-hook
.
Looking through Emacs' standard hooks I cannot immediately identify a good candidate, but maybe there is a non-obvious one that could do this job.
Alternatively, is there some other way that I could simulate/approximate such a hook's functionality?
1 Of course, in-a-while
refers to some user-settable parameter corresponding to some minimum time interval, say 15 minutes. The event I'm interested in is the first key press after a period of inactivity longer than this interval. By "inactivity" I mean the state where Emacs detects no user interaction: no key-presses, no mouse clicks, etc.