2

Do any versions of androids web browser detect javascript shake events? Something like this:
window.addEventListener('devicemotion', this, false);
I can't seem to find any information on this.

I am using WKShake which is refrenced here: Javascript. Listen for iPhone shake event?
and am wondering if this is going to work on android as well.

Community
  • 1
  • 1
pizza247
  • 3,869
  • 7
  • 33
  • 47

3 Answers3

3

After some research, I have discovered that the android browser does not have access to accelerometer data. Perhaps some time in the future they will allow the browser to access this data.

pizza247
  • 3,869
  • 7
  • 33
  • 47
1

Shake.js (http://functionn.blogspot.com/2012/03/shakejs-custom-shake-event-javascript.html) is a custom 'shake' event JavaScript plugin for mobile web browsers using device accelerometer. Your web browser must support the devicemotion event for this plugin to work. Shake.js uses built-in feature detection to determine if it can run in your web browser. It will terminate silently on non-supporting browsers.

Hirvesh
  • 7,636
  • 15
  • 59
  • 72
0

Here's an implementation of a JavaScript shake method for Android built on top of PhoneGap's accelerometer API - github link

Paul Beusterien
  • 27,542
  • 6
  • 83
  • 139
  • this is closer to what I'm after, but again, I'm wanting to see this work in the browser, not a phone gap native applicaiton. – pizza247 May 02 '11 at 14:48
  • @jtmkrueger As your answer says, the browser doesn't have direct access to the accelerometer, as well as a bunch of other device capabilities. That is the "Gap" that PhoneGap is designed to fill. – Paul Beusterien May 02 '11 at 15:52