aboutsummaryrefslogtreecommitdiff
path: root/ext/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js')
-rw-r--r--ext/js/language/text-scanner.js38
1 files changed, 37 insertions, 1 deletions
diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js
index bdbc117e..13db91d5 100644
--- a/ext/js/language/text-scanner.js
+++ b/ext/js/language/text-scanner.js
@@ -88,6 +88,9 @@ export class TextScanner extends EventDispatcher {
/** @type {?import('text-scanner').SelectionRestoreInfo} */
this._selectionRestoreInfo = null;
+ /** @type {MouseEvent | null} */
+ this._lastMouseMove = null;
+
/** @type {boolean} */
this._deepContentScan = false;
/** @type {boolean} */
@@ -546,6 +549,7 @@ export class TextScanner extends EventDispatcher {
*/
_onMouseMove(e) {
this._scanTimerClear();
+ this._lastMouseMove = e;
const inputInfo = this._getMatchingInputGroupFromEvent('mouse', 'mouseMove', e);
if (inputInfo === null) { return; }
@@ -554,6 +558,28 @@ export class TextScanner extends EventDispatcher {
}
/**
+ * @param {KeyboardEvent} e
+ */
+ _onKeyDown(e) {
+ if (this._lastMouseMove !== null && (e.ctrlKey || e.shiftKey || e.altKey || e.metaKey)) {
+ 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,
+ button: this._lastMouseMove.button,
+ buttons: this._lastMouseMove.buttons,
+ relatedTarget: this._lastMouseMove.relatedTarget
+ });
+ this._onMouseMove(syntheticMouseEvent);
+ }
+ }
+
+ /**
* @param {MouseEvent} e
* @returns {boolean|void}
*/
@@ -1050,7 +1076,7 @@ export class TextScanner extends EventDispatcher {
} else if (this._arePointerEventsSupported()) {
eventListenerInfos = this._getPointerEventListeners(capture);
} else {
- eventListenerInfos = this._getMouseEventListeners(capture);
+ eventListenerInfos = [...this._getMouseEventListeners(capture), ...this._getKeyboardEventListeners(capture)];
if (this._touchInputEnabled) {
eventListenerInfos.push(...this._getTouchEventListeners(capture));
}
@@ -1103,6 +1129,16 @@ export class TextScanner extends EventDispatcher {
* @param {boolean} capture
* @returns {import('event-listener-collection').AddEventListenerArgs[]}
*/
+ _getKeyboardEventListeners(capture) {
+ return [
+ [this._node, 'keydown', this._onKeyDown.bind(this), capture]
+ ];
+ }
+
+ /**
+ * @param {boolean} capture
+ * @returns {import('event-listener-collection').AddEventListenerArgs[]}
+ */
_getTouchEventListeners(capture) {
return [
[this._node, 'auxclick', this._onAuxClick.bind(this), capture],