I had two previous posts on accessing the accelerometer and gyroscope data on mobile devices via JavaScript. Part I mentions how to access them, and Part II is about the differences between devices.

With these learnings I put together a JavaScript file. By default it returns (almost) the same values for different devices. So you can program your logic on top of it and do not worry about these differences.

It can be found on GitHub