Awesome Open Source
Awesome Open Source


small library to detect shake in mobile devices

How to use this

Create Method like:

detectShake() {
//Create object
var myShakeEvent = new Shake();
// Start listening to device motion

// Register a shake event listener on window with your callback
window.addEventListener("shake", shakeEventDidOccur, false);

//function to call when shake occurs
function shakeEventDidOccur() {
 // myShakeEvent.reset();
 //do something on shake
 console.log("Shake Occur");

FOR IOS we may require permission to access device motion sensor (using user action)

window.document.onclick = function () {
      if (
        typeof (DeviceMotionEvent as any).requestPermission()
          .requestPermission === "function"
      ) {
        (DeviceMotionEvent as any)
          .then((permissionState) => {
            if (permissionState === "granted") {
      } else {
        // handle regular non iOS 13+ devices

For Android device simply use detectshake method

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,158,774
Es6 (1,158,773
Typescript (307,126
Es5 (687
Shake Detection (15