fixup: paging with Space and Shift-Space

This commit is contained in:
tophf 2020-11-06 22:31:23 +03:00
parent 2d415746e0
commit 6801d8804e

View File

@ -94,17 +94,21 @@ onDOMready().then(() => {
$('#search').focus(); $('#search').focus();
return; return;
} }
if (ctrl || inTextInput || if (ctrl || inTextInput && event.target !== input) {
key === ' ' && !input.value /* Space or Shift-Space is for page down/up */) {
return; return;
} }
const time = performance.now(); const time = performance.now();
if (key.length === 1) { if (key.length === 1) {
input.focus();
if (time - prevTime > 1000) { if (time - prevTime > 1000) {
input.value = ''; input.value = '';
} }
// Space or Shift-Space is for page down/up
if (key === ' ' && !input.value) {
input.blur();
} else {
input.focus();
prevTime = time; prevTime = time;
}
} else } else
if (key === 'Enter' && focusedLink) { if (key === 'Enter' && focusedLink) {
focusedLink.dispatchEvent(new MouseEvent('click', {bubbles: true})); focusedLink.dispatchEvent(new MouseEvent('click', {bubbles: true}));