Implementation of W3C Proximity Events
Latest commit d671b6a Jul 4, 2013 @marcoscaceres Update

Proximity Sensors

This is a reference implementation of the W3C's Proximity Events specification. It can also be used as a polyfill.


This is an unsupported component with an indefinite lifetime. This should be used for evaluation purposes only and should not be used for production level applications.

Using for testing

Just do this and you are good to go:

  • window.addEventListener('deviceproximity', function(e) { ... })
  • window.addEventListener('userproximity', function(e) { ... })


  • window.ondeviceproximity = function(e){ ... }
  • window.onuserproximity = function(e){ ... }


Using as polyfill or with Node.js

Depending on what you want to do, you can remove the "FakeSensor" and replace it with a real sensor (so long as you use the same method names).