Skip to content

Instantly share code, notes, and snippets.

@thomaskimura
Last active August 29, 2015 13:58
Show Gist options
  • Save thomaskimura/10341757 to your computer and use it in GitHub Desktop.
Save thomaskimura/10341757 to your computer and use it in GitHub Desktop.
Finally
<script>
//KEYBOARD NAVIGATION FOR PERMALINK
document.body.onkeydown = function(e){
if (e == null) {
keycode = event.keyCode;
} else {
keycode = e.which;
}
if(keycode == 39){
$('#sb-site').addClass( "leftAnimate" ); //this class will animate the element to the left
setTimeout(function(){
window.location = $('#nextPost').attr('href');
},300);
} else if(keycode == 37){
$('#sb-site').addClass( "rightAnimate" ); /this class will animate the element to the right
setTimeout(function(){
window.location = $('#previousPost').attr('href');
},300);
}
else if(keycode == 191){
$("#sb-site").addClass( "fadeAnimate" );
setTimeout(function(){
window.location = $('#random').attr('href');
},300);
}
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment