I've been googling for a week now and I just don't understand how to combine it all :(
I'm making a horizontal website similar to this, except I want to be able to navigate using arrow keys to move back and forth between sections of the horizontal page similar to this.
The relevant research I've found the following pages:
- stackoverflow.com/questions/2168739/using-arrow-keys-with-jquery-scrollto
- flesler.blogspot.com/2008/02/jqueryserialscroll.html
- stackoverflow.com/questions/1402698/binding-arrow-keys-in-js-jquery
- jqueryfordesigners.com/adding-keyboard-navigation/
- tympanus.net/codrops/2010/06/02/smooth-vertical-or-horizontal-page-scrolling-with-jquery
The best I've been able to come up with is this but its not working:
$(document).bind('keydown',function(evt) {
switch(evt.keyCode) {
case 37:
evt.preventDefault();
$.scrollTo('+=564px', 800, { axis:'x' });
break;
}
});
$(document).bind('keydown',function(evt) {
switch(evt.keyCode) {
case 39:
evt.preventDefault();
$.scrollTo('-=564px', 800, { axis:'x' });
break;
}
});
Isn't there just a way to create anchors or div classes that can be scrolled to on using the arrow keys or clicking arrow buttons? I'm pretty lost here. Maybe I'm asking too much, but if someone could point me in the right direction I'd be grateful, thanks :)