Last active
September 18, 2019 14:32
-
-
Save KerberosMorphy/8cdba398d8c47633d0878daade689548 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).keydown(function(e) { | |
switch(e.which) { | |
case 37: // left | |
console.log('LEFT'); | |
if($('.prev-link').length && !$('.prev-link.disabled').length) { | |
var ref = $('h2 a.prev-link')[0]["href"] | |
window.location.assign(ref); | |
} | |
break; | |
case 39: // right | |
console.log('RIGHT'); | |
if($('.next-link').length && !$('.next-link.disabled').length) { | |
var ref = $('h2 a.next-link')[0]["href"] | |
window.location.assign(ref); | |
} | |
break; | |
default: return; // exit this handler for other keys | |
} | |
e.preventDefault(); // prevent the default action (scroll / move caret) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment