mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-20 15:26:15 +08:00
fix(layout emulator): shift + caps lock not working correctly sometimes when emulating a layout
closes #4743
This commit is contained in:
parent
a30b36718c
commit
4d2a8f3180
|
@ -6,14 +6,6 @@ import * as Notifications from "../elements/notifications";
|
|||
export async function getCharFromEvent(
|
||||
event: JQuery.KeyDownEvent
|
||||
): Promise<string | null> {
|
||||
function emulatedLayoutShouldShiftKey(
|
||||
event: JQuery.KeyDownEvent,
|
||||
newKeyPreview: string
|
||||
): boolean {
|
||||
if (capsState) return Misc.isASCIILetter(newKeyPreview) !== event.shiftKey;
|
||||
return event.shiftKey;
|
||||
}
|
||||
|
||||
let layout;
|
||||
|
||||
try {
|
||||
|
@ -205,9 +197,9 @@ export async function getCharFromEvent(
|
|||
return null;
|
||||
}
|
||||
}
|
||||
const newKeyPreview = layoutMap[mapIndex][0];
|
||||
const shift = emulatedLayoutShouldShiftKey(event, newKeyPreview) ? 1 : 0;
|
||||
const char = layoutMap[mapIndex][shift];
|
||||
const charIndex =
|
||||
(capsState && !event.shiftKey) || (!capsState && event.shiftKey) ? 1 : 0;
|
||||
const char = layoutMap[mapIndex][charIndex];
|
||||
if (char) {
|
||||
return char;
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue