Last active
July 5, 2017 14:45
-
-
Save Lewiscowles1986/ba8c0a7a69b3d4178a5af19b6dde486f to your computer and use it in GitHub Desktop.
Keyboard Gallery Navigation
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
window.addEventListener('keyup', function(k) { | |
switch(k.code) { | |
case "ArrowRight": | |
document.querySelector('.nav.controls .link.next').click(); | |
break; | |
case "ArrowUp": | |
document.querySelector('.nav.controls .link.up').click(); | |
break; | |
case "ArrowLeft": | |
document.querySelector('.nav.controls .link.prev').click(); | |
// window.history.back(); | |
break; | |
default: | |
console.log("Key Pressed:", k); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
class="nav controls"
class="link next"
class="link prev"
(you can uncomment line 11 if there are no previous links)class="link up"
Example