IdleDetector: userState property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
Note: This feature is available inDedicated Web Workers.
TheuserState read-only property of theIdleDetector interface returns a string indicating whether the user has interacted with the device since the call tostart().
In this article
Value
Either"active" or"idle" ifIdleDetector.start() has been called, ornull otherwise.
Examples
In the following example, thechange callback prints the status ofuserState andscreenState to the console.
js
idleDetector.addEventListener("change", () => { const userState = idleDetector.userState; const screenState = idleDetector.screenState; console.log(`Idle change: ${userState}, ${screenState}.`);});Specifications
| Specification |
|---|
| Idle Detection API> # api-idledetector-userstate> |