The Proximity Events API allows web applications to get the access to the data from the device's proximity sensors, detecting whether there is a physical object near the device.
The first approach to supporting proximity sensor on the web - as a standalone API - was implemented in Firefox. Since then the specification was rewritten to make use of the new Generic Sensors API, but no vendor implemented that spec as of September 2016.
The old, standalone API
- An event fired when the device has sensed the physical object proximity, containing approximate distance information.
- An event fired when the device has roughly sensed the physical object proximity, containing boolean
The new, generic API
sensor = new ProximitySensor()
- Creates an object serving as an accessor to the proximity sensor readings.
- An event fired when the physical object proximity has changed, containing approximate distance information in cm (
event.reading.distance) and boolean
- Starts listening for the sensor readings.