I need an event that gives one click right, up, down or left. Below is the logic:
if (gesture.left) { Click Event for left direction } Else if (gesture.right) { Click Event for right direction }
I need to detect only one condition after the click button
Try this code:
$(function(){
$('html').keydown(function(e){
if(e.keyCode == 37) { // left
}
else if(e.keyCode == 39) { // right
}
else if(e.keyCode == 38) { // up
}
else if(e.keyCode == 40) { // down
}
});
});
arrow keys are only triggered by onkeydown, not onkeypress keycodes are:
left = 37;
up = 38;
right = 39;
down = 40;
or you can look at this thread sample
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.