Fix spacebar being eaten by Vivaldi, and repeated arrow keys causing scrolling

This commit is contained in:
Eevee (Evelyn Woods) 2021-01-11 18:10:34 -07:00
parent 602f16be8c
commit 0f6f912055

View File

@ -544,11 +544,24 @@ class Player extends PrimaryView {
key_target.addEventListener('keydown', ev => { key_target.addEventListener('keydown', ev => {
if (! this.active) if (! this.active)
return; return;
// Ignore IME composition and repeat events
if (ev.isComposing || ev.keyCode === 229 || ev.repeat)
return;
this.using_touch = false; this.using_touch = false;
// Ignore IME composition
if (ev.isComposing || ev.keyCode === 229)
return;
// For key repeat of keys we're listening to, we still want to preventDefault, but we
// don't actually want to do anything. That would be really hard except the only keys
// we care about preventDefaulting are action ones
// TODO what if a particular browser does something for p/,/.?
if (ev.repeat) {
if (this.key_mapping[ev.key]) {
ev.preventDefault();
ev.stopPropagation();
}
return;
}
if (ev.key === 'p' || ev.key === 'Pause') { if (ev.key === 'p' || ev.key === 'Pause') {
this.toggle_pause(); this.toggle_pause();
return; return;
@ -602,7 +615,6 @@ class Player extends PrimaryView {
this.restart_level(); this.restart_level();
} }
} }
return;
} }
// Don't scroll pls // Don't scroll pls
ev.preventDefault(); ev.preventDefault();