summaryrefslogtreecommitdiff
path: root/ext/js/language/text-scanner.js
diff options
context:
space:
mode:
authorKuuuube <61125188+Kuuuube@users.noreply.github.com>2024-05-22 23:07:07 -0400
committerGitHub <noreply@github.com>2024-05-23 03:07:07 +0000
commitbbb19669c27a4216ae11937650da173165e72978 (patch)
treea4a96ad5514a6d60e758ffb7ed9c913c5fa21a8a /ext/js/language/text-scanner.js
parentd19b898792bffed8ab2d5724472e5b65a5f5b146 (diff)
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
Diffstat (limited to 'ext/js/language/text-scanner.js')
-rw-r--r--ext/js/language/text-scanner.js11
1 files changed, 6 insertions, 5 deletions
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