I want the user to be able to load the next or previous page when they press left or right on the keyboard. The following and previous links for each page are contained in two buttons.
html ...
<a href="/page-link-prev" class="prev button">< Prev</a>
<a href="/page-link-next" class="next button">Next ></a>
In some jquery, I found that it registers right-clicks, but obviously does not change the url, it just shows a warning.
$(function() {
$(document).keyup(function(e) {
switch(e.keyCode) {
case 37 : alert('You pressed Left'); break;
case 39 : alert('You pressed Right'); break;
}
});
});
source
share