DeviceProximityEvent

  • Revision slug: DOM/DeviceProximityEvent
  • Revision title: DeviceProximityEvent
  • Revision id: 313203
  • Created:
  • Creator: jswisher
  • Is current revision? No
  • Comment copyediting

Revision Content

The DeviceProximityEvent provides information about the distance of a nearby physical object using the proximity sensor of a device.

Attributes

max
Read only. The maximum sensing distance the sensor is able to report, in centimeters.
min
Read only. The minimum sensing distance the sensor is able to report, in centimeters. Ususally zero.
value
Read only. The current device proximity, in centimeters.

Examples

window.addEventListener('deviceproximity', function(event) {
  console.log("Current = " + event.value +  " Max = " + event.max +  " Min = " + event.min);
});

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatNo() }} {{ CompatNo() }} {{ CompatGeckoMobile("15.0") }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}

Specifications

Specification Status Comment
{{ SpecName('ProximityEvents', '', 'Proximity Events') }} {{ Spec2('Proximity Events') }} Initial specification

See also

  • {{domxref("UserProximityEvent")}}

Revision Source

<p>The <code>DeviceProximityEvent</code> provides information about the distance of a nearby physical object using the proximity sensor of a device.</p>
<h2 id="Attributes">Attributes</h2>
<dl>
  <dt>
    max</dt>
  <dd>
    Read only. The maximum sensing distance the sensor is able to report, in centimeters.</dd>
  <dt>
    min</dt>
  <dd>
    Read only. The minimum sensing distance the sensor is able to report, in centimeters. Ususally zero.</dd>
  <dt>
    value</dt>
  <dd>
    Read only. The current device proximity, in centimeters.</dd>
</dl>
<h2 id="Examples">Examples</h2>
<pre>
window.addEventListener('deviceproximity', function(event) {
&nbsp; console.log(<code>"Current = " + event.value +&nbsp; " Max = " + event.max +&nbsp; " Min = " + event.min</code>);
});</pre>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Chrome for Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatGeckoMobile("15.0") }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="Specifications" name="Specifications">Specifications</h2>
<table class="standard-table" height="49" width="1000">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{ SpecName('ProximityEvents', '', 'Proximity Events') }}</td>
      <td>{{ Spec2('Proximity Events') }}</td>
      <td>Initial specification</td>
    </tr>
  </tbody>
</table>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{domxref("UserProximityEvent")}}</li>
</ul>
Revert to this revision