eslint
This commit is contained in:
parent
2b455fcd34
commit
c9ad6dbf10
1 changed files with 20 additions and 18 deletions
|
|
@ -644,36 +644,38 @@ aria-label="Show hidden lines"></button>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function showHelp() {
|
function showHelp() {
|
||||||
document.getElementById("help-overlay").style.display = "block";
|
document.getElementById('help-overlay').style.display = 'block';
|
||||||
let help = `<h2 id="help-title">Keyboard shortcuts</h2>`;
|
let help = '<h2 id="help-title">Keyboard shortcuts</h2>';
|
||||||
help += "<p>Press <kbd>←</kbd> or <kbd>→</kbd> to navigate between chapters</p>";
|
help += '<p>Press <kbd>←</kbd> or <kbd>→</kbd> to navigate between chapters</p>';
|
||||||
help += "<p>Press <kbd>s</kbd> to search in the book</p>";
|
help += '<p>Press <kbd>s</kbd> to search in the book</p>';
|
||||||
help += "<p>Press <kbd>?</kbd> to show this help</p>";
|
help += '<p>Press <kbd>?</kbd> to show this help</p>';
|
||||||
help += "<p>Press <kbd>Esc</kbd> to hide this help</p>";
|
help += '<p>Press <kbd>Esc</kbd> to hide this help</p>';
|
||||||
|
|
||||||
document.getElementById("help-overlay").innerHTML = help;
|
document.getElementById('help-overlay').innerHTML = help;
|
||||||
|
|
||||||
document.addEventListener('keydown', function (e) {
|
document.addEventListener('keydown', function(e) {
|
||||||
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { return; }
|
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (e.key) {
|
switch (e.key) {
|
||||||
case 'Escape':
|
case 'Escape':
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
hideHelp();
|
hideHelp();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function hideHelp() {
|
function hideHelp() {
|
||||||
document.getElementById("help-overlay").style.display = "none";
|
document.getElementById('help-overlay').style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Usually needs the Shift key to be pressed
|
// Usually needs the Shift key to be pressed
|
||||||
switch (e.key) {
|
switch (e.key) {
|
||||||
case '?':
|
case '?':
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
showHelp();
|
showHelp();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rest of the keys are only active when the Shift key is not pressed
|
// Rest of the keys are only active when the Shift key is not pressed
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue