From bbb19669c27a4216ae11937650da173165e72978 Mon Sep 17 00:00:00 2001 From: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Date: Wed, 22 May 2024 23:07:07 -0400 Subject: Fix detection of modifiers on Firefox in textarea or input and modifiers sent through virtual keycodes (#986) * Fix firefox modifiers in textarea and input * Fix modifiers sent through virtual keycodes * Styling fix * Fix wording in comment --- ext/js/language/text-scanner.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'ext/js/language') diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js index 7c1b5b33..17809300 100644 --- a/ext/js/language/text-scanner.js +++ b/ext/js/language/text-scanner.js @@ -561,17 +561,18 @@ export class TextScanner extends EventDispatcher { * @param {KeyboardEvent} e */ _onKeyDown(e) { - if (this._lastMouseMove !== null && (e.ctrlKey || e.shiftKey || e.altKey || e.metaKey)) { + const modifiers = getActiveModifiers(e); + if (this._lastMouseMove !== null && (modifiers.length > 0)) { if (this._inputtingText()) { return; } const syntheticMouseEvent = new MouseEvent(this._lastMouseMove.type, { screenX: this._lastMouseMove.screenX, screenY: this._lastMouseMove.screenY, clientX: this._lastMouseMove.clientX, clientY: this._lastMouseMove.clientY, - ctrlKey: e.ctrlKey, - shiftKey: e.shiftKey, - altKey: e.altKey, - metaKey: e.metaKey, + ctrlKey: modifiers.includes('ctrl'), + shiftKey: modifiers.includes('shift'), + altKey: modifiers.includes('alt'), + metaKey: modifiers.includes('meta'), button: this._lastMouseMove.button, buttons: this._lastMouseMove.buttons, relatedTarget: this._lastMouseMove.relatedTarget -- cgit v1.2.3