Idle Detection API - Web APIs | MDN
Idle Detection API - Web APIs | MDN
developer.mozilla.org
Idle Detection API - Web APIs | MDN

The Idle Detection API provides a means to detect the user's idle status, active, idle, and locked, specifically, and to be notified of changes to idle status without polling from a script.