Skip to content

Instantly share code, notes, and snippets.

@sandeshdamkondwar
Created April 20, 2013 19:27
Show Gist options
  • Save sandeshdamkondwar/5427085 to your computer and use it in GitHub Desktop.
Save sandeshdamkondwar/5427085 to your computer and use it in GitHub Desktop.
Mouse Press Events
$('*').hover(function() {
$(this).data('hover', 1); //store in that element that the mouse is over it
},
function() {
$(this).data('hover', 0); //store in that element that the mouse is no longer over it
});
window.isHovering = function (selector) {
return $(selector).data('hover') ? true : false; //check element for hover property
}
$(document).keydown(function(e){
if (e.keyCode == 37 ) {
if (isHovering('.controlcontent_r'))
moveSlide("previous");
else if (isHovering('#mainSlide'))
$('#mainSlide .slidesjs-next').trigger('click');
} else if (e.keyCode == 39 ) {
if (isHovering('.controlcontent_r'))
moveSlide("next");
else if (isHovering('#mainSlide'))
$('#mainSlide .slidesjs-previous').trigger('click');
}
});
// 37 - left
// 38 - up
// 39 - right
// 40 - down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment