Allow keyboard navigation on reader page (#124)

This commit is contained in:
Alex Ling 2020-11-24 03:57:38 +00:00
parent 7792d3426e
commit 011123f690
2 changed files with 18 additions and 0 deletions

View File

@ -292,3 +292,19 @@ const flipPage = (isNext) => {
replaceHistory(newIdx); replaceHistory(newIdx);
saveProgress(newIdx); saveProgress(newIdx);
}; };
/**
* Handle the global keydown events
*
* @function keyHandler
* @param {event} event - The $event object
*/
const keyHandler = (event) => {
const mode = getProp('mode');
if (mode === 'continuous') return;
if (event.key === 'ArrowLeft' || event.key === 'j')
flipPage(false);
if (event.key === 'ArrowRight' || event.key === 'k')
flipPage(true);
};

View File

@ -17,6 +17,8 @@
flipAnimation: null flipAnimation: null
}"> }">
<div @keydown.window.debounce="keyHandler($event)"></div>
<div class="uk-container uk-container-small"> <div class="uk-container uk-container-small">
<div id="alert"></div> <div id="alert"></div>
<div x-show="loading"> <div x-show="loading">