Layout emulator: Ignore forced compose input and keys with modifiers (#1965)

* Undo forced compose input when using emulator

* Don't emulate keys with modifiers

Ctrl everywhere and Alt only on Linux (because Firefox uses Alt shortcuts
on Linux).
This commit is contained in:
SeerLite 2021-10-07 14:52:40 -03:00 committed by GitHub
parent 57f6eec430
commit 4234cb3c1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -728,7 +728,13 @@ $(document).keydown((event) => {
correctShiftUsed = ShiftTracker.isUsingOppositeShift(event) !== false;
}
if (Config.layout !== "default") {
if (
Config.layout !== "default" &&
!(
event.ctrlKey ||
(event.altKey && window.navigator.platform.search("Linux") > -1)
)
) {
const char = LayoutEmulator.getCharFromEvent(event);
if (char !== null) {
event.preventDefault();
@ -773,6 +779,14 @@ $("#wordsInput").on("input", (event) => {
const realInputValue = event.target.value.normalize();
const inputValue = realInputValue.slice(1);
// input will be modified even with the preventDefault() in
// beforeinput/keydown if it's part of a compose sequence. this undoes
// the effects of that and takes the input out of compose mode.
if (Config.layut !== "default" && inputValue.length >= TestLogic.input.current.length) {
setWordsInput(" " + TestLogic.input.current);
return;
}
if (realInputValue.length === 0 && TestLogic.input.current.length === 0) {
// fallback for when no Backspace keydown event (mobile)
backspaceToPrevious();