WakeLockSentinel: release event

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The release event of the WakeLockSentinel interface is fired when the sentinel object's handle has been released.

A WakeLockSentinel can be released manually via the release() method, or automatically via the platform wake lock. This can happen if the document becomes inactive or looses visibility, if the device is low on power or the user turns on a power save mode.

Syntax

Use the event name in methods like addEventListener(), or set an event-handler property.

addEventListener('release', (event) => { })

onrelease = (event) => { }

Event type

A generic Event.

Examples

This example updates the UI if the wake lock is released.

wakeLock.addEventListener('release', () => {

  // if wake lock is released alter the UI accordingly
  statusElement.textContent = 'Wake Lock has been released';
});

Specifications

Specification
Screen Wake Lock API
# the-onrelease-attribute

Browser compatibility

BCD tables only load in the browser