Window: devicelight event

This is an archived page. It's not actively maintained.

Obsolete
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

The devicelight event is fired when fresh data is available from a light sensor.

Note: This event has been disabled by default in Firefox 62, behind the device.sensors.ambientLight.enabled preference (bug 1462308).

Bubbles No
Cancelable No
Interface SensorCallback
Target DefaultView (window)

Other properties

Property Type Description
value Read only Double (float) The sensor data for ambient light in Lux.
min Read only Double (float) The minimum value in the range the sensor detects (if available, 0 otherwise).
max Read only Double (float) The maximum value in the range the sensor detects (if available, 0 otherwise).

Examples

window.addEventListener('devicelight', function(event) {
  console.log(event.value);
});

Specifications

Specification Status Comment
Ambient Light Sensor
The definition of 'Ambient Light Events' in that specification.
Candidate Recommendation Removed from specification

Browser compatibility

BCD tables only load in the browser

See also