How can I bind the up arrow (or any other key) to do the same work as scroll up programatically w/ jQuery or Javascript?
I'm using this code to detect the up & down arrow click:
$(document).keydown(function(e) {
switch(e.which) {
case 38: // up
console.log("up");
break;
case 40: // down
console.log("down");
break;
default: return; // exit this handler for other keys
}
e.preventDefault(); // prevent the default action (scroll / move caret)
});
So when I click the down arrow in this case, it should call "mouse scroll down".
Reason for this: I can scroll through content in a popup modal on my website with swipe up and down on a mobile device, and with mouse scrolling. What if you have a laptop and no mouse? Arrow up/down doesn't work...