Merge pull request #87 from funkill/keys_navigation

add navigation by arrows
This commit is contained in:
Mathieu David 2015-12-30 16:37:09 +01:00
commit 41462e8b2d
2 changed files with 19 additions and 2 deletions

View File

@ -23,6 +23,23 @@ $( document ).ready(function() {
hljs.highlightBlock(block);
});
var KEY_CODES = {
PREVIOUS_KEY: 37,
NEXT_KEY: 39
};
$(document).on('keydown', function (e) {
switch (e.keyCode) {
case KEY_CODES.NEXT_KEY:
e.preventDefault();
window.location.href = $('.nav-chapters.next').attr('href');
break;
case KEY_CODES.PREVIOUS_KEY:
e.preventDefault();
window.location.href = $('.nav-chapters.previous').attr('href');
break;
}
});
// Interesting DOM Elements
var html = $("html");

View File

@ -84,13 +84,13 @@
</div>
{{#previous}}
<a href="{{link}}" class="nav-chapters previous">
<a href="{{link}}" class="nav-chapters previous" title="&larr;">
<i class="fa fa-angle-left"></i>
</a>
{{/previous}}
{{#next}}
<a href="{{link}}" class="nav-chapters next">
<a href="{{link}}" class="nav-chapters next" title="&rarr;">
<i class="fa fa-angle-right"></i>
</a>
{{/next}}