fix modifier keys not being sent on firefox

This commit is contained in:
theduck32 2025-05-24 17:00:33 -04:00
parent 4cb5aa45ae
commit b5299a086e
1 changed files with 24 additions and 0 deletions

View File

@ -208,6 +208,14 @@ export default class Keyboard {
return; return;
} }
// The event gives us some very useful info about modkeys but
// when fingerprinting is on, it only stores this info without
// sending it, so we have to manually send the modkeys ourselves
if (browser.isFirefox()) {
this._updateModifierState(false, false);
this._updateModifierState(e, true);
}
this._sendKeyEvent(keysym, code, true, numlock, capslock); this._sendKeyEvent(keysym, code, true, numlock, capslock);
} }
@ -245,6 +253,22 @@ export default class Keyboard {
} }
} }
_updateModifierState(e, isKeyDown) {
const modMap = {
shiftKey: KeyTable.XK_Shift_L,
ctrlKey: KeyTable.XK_Control_L,
altKey: KeyTable.XK_Alt_L,
metaKey: KeyTable.XK_Super_L
};
for (let key in modMap) {
if(!e) this._sendKeyEvent(modMap[key], key, false);
if (e[key]) {
this._sendKeyEvent(modMap[key], key, isKeyDown);
}
}
}
_interruptAltGrSequence() { _interruptAltGrSequence() {
if (this._altGrArmed) { if (this._altGrArmed) {
this._altGrArmed = false; this._altGrArmed = false;