Skip to content

Instantly share code, notes, and snippets.

@tedrick
Last active December 21, 2015 13:39
Show Gist options
  • Save tedrick/109eb51d73932aeb3f47 to your computer and use it in GitHub Desktop.
Save tedrick/109eb51d73932aeb3f47 to your computer and use it in GitHub Desktop.
Basic keyboard navigation for Story Map Series (place in index.html's custom JS section in the tpl-ready handler)
$(document).keyup(function(e){
//Right > forward
if (e.which === 39 || e.which === 34) {
var currentIndex = app.data.getCurrentEntryIndex();
if (currentIndex < app.data.getStoryLength() -1) {
topic.publish("story-navigate-entry", currentIndex + 1);
console.log('right');
console.log(currentIndex);
}
}
//Left > backward
else if (e.which === 37 || e.which === 33) {
var currentIndex = app.data.getCurrentEntryIndex()
if (currentIndex > 0) {
topic.publish("story-navigate-entry", currentIndex - 1);
console.log('left');
console.log(currentIndex);
}
}
console.log(e.which);
});
@tedrick
Copy link
Author

tedrick commented Dec 21, 2015

@acarroll51 - I mentioned this last week- basic keyboard navigation for the Story Map Series

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment