Table of Contents

Class IdleDetector

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll
NOTE
Experimental
The IdleDetector interface of the 'idle_detection_api' provides methods and events for detecting user activity on a device or screen.
[Value("IdleDetector")]
public class IdleDetector : EventTarget
Inheritance
IdleDetector
Inherited Members

Remarks

This interface requires a secure context.

See also on MDN

Constructors

IdleDetector()

NOTE
Experimental
The IdleDetector() constructor creates a new IdleDetector
object which provides events indicating when the user is no longer interacting
with their device or the screen has locked.
public IdleDetector()

Remarks

Properties

Onchange

[Value("onchange")]
public EventHandlerNonNull Onchange { get; set; }

Property Value

EventHandlerNonNull

ScreenState

NOTE
Experimental
The screenState read-only property of the IdleDetector interface
returns a string indicating whether the screen is locked, one of "locked" or
"unlocked".
[Value("screenState")]
public ScreenIdleState? ScreenState { get; }

Property Value

ScreenIdleState?

Either "locked" or "unlocked" if Start(IdleOptions) has been called, or null otherwise.

Remarks

UserState

NOTE
Experimental
The userState read-only property of the IdleDetector interface returns a string indicating whether the user has interacted with the device since the call to start().
[Value("userState")]
public UserIdleState? UserState { get; }

Property Value

UserIdleState?

Either "active" or "idle" if Start(IdleOptions) has been called, or null otherwise.

Remarks

Methods

RequestPermission()

NOTE
Experimental
The requestPermission() static method of the IdleDetector
interface returns a 'Promise' that resolves with a string when the user has chosen
whether to grant the origin access to their idle state. Resolves with
"granted" on acceptance and "denied" on refusal.
[Value("requestPermission")]
public static Task<PermissionState> RequestPermission()

Returns

Task<PermissionState>

A Promise that resolves with &quot;granted&quot; or &quot;denied&quot;.

Remarks

Start(IdleOptions)

NOTE
Experimental
The start() method of the IdleDetector interface returns a
Promise that resolves when the detector starts listening for changes in the
user&apos;s idle state. This
method takes an optional options object with the threshold in milliseconds
where inactivity should be reported and signal for an AbortSignal to abort
the idle detector.
[Value("start")]
public Task<GlobalObject.Undefined> Start(IdleOptions options = null)

Parameters

options IdleOptions

Returns

Task<GlobalObject.Undefined>

A Promise.

Remarks