diff --git a/src/theme/book.js b/src/theme/book.js index 1560ed5f..89f71c45 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -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"); diff --git a/src/theme/index.hbs b/src/theme/index.hbs index a8fdae1e..38b18f99 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -84,13 +84,13 @@ {{#previous}} - {{/previous}} {{#next}} - {{/next}}