mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-05 05:17:51 +08:00
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:
parent
57f6eec430
commit
4234cb3c1c
1 changed files with 15 additions and 1 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue