Skip to content

davidgodzsak/mouse-shake.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mouse-shake.js

Detect mouse shaking event in JavaScript

##Basic usage

Add mouse-shake.js to your project e.g:

<script src="./js/mouse-shake.js"></script>

Then add a mouseshake EventListener on document to your JavaScript:

document.addEventListener("mouseshake",function(e){
  console.log("Shake it original!");
});

##Using with jQuery

jQuery .on method will detect the event too:

$(document).on("mouseshake", function(e) {
  console.log("Shake it jQuery!");
});

##Firing the event

When the user shakes their mouse, the script will detect it. It sums the direction changes under a certain time. When it exceeds the limit, the event is fired.

##Todo

  • Detecting the events of mouse shake + mouse buttons pressed
  • Add the ability to configure event target, detection on target
  • Add finger shake detection for mobile devices

About

Detect mouse shaking event in JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published