Question

I am working on mobile site that donate if you are not using your phone.

I was searching on the internet and I found similar project.

http://tap.unicefusa.org/mobile

you need to open it by mobile device.

I am worried how can I detect if the user hold his mobile or he put it down on table or something by jQuery mobile or javascript ?

any Idea how they did that?

Was it helpful?

Solution

In a webpage you can access the Gyroscope using DeviceMotionEvent.

simply check if that even exists prior to use it as plenty of mobiles do not allow or do not have such feature.

a good idea on how to start might be an old post from Peter's blog.

There's also some javascript libraries such as gyro.js that you might try.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top