@@ -110,7 +110,7 @@ function updateUI(): void {
110
110
}
111
111
}
112
112
113
- function backspaceToPrevious ( ) : void {
113
+ async function backspaceToPrevious ( ) : Promise < void > {
114
114
if ( ! TestState . isActive ) return ;
115
115
116
116
if (
@@ -152,7 +152,7 @@ function backspaceToPrevious(): void {
152
152
}
153
153
TestWords . words . decreaseCurrentIndex ( ) ;
154
154
TestUI . setActiveWordElementIndex ( TestUI . activeWordElementIndex - 1 ) ;
155
- TestUI . updateActiveElement ( true ) ;
155
+ await TestUI . updateActiveElement ( true ) ;
156
156
Funbox . toggleScript ( TestWords . words . getCurrent ( ) ) ;
157
157
void TestUI . updateActiveWordLetters ( ) ;
158
158
@@ -337,7 +337,7 @@ async function handleSpace(): Promise<void> {
337
337
}
338
338
}
339
339
TestUI . setActiveWordElementIndex ( TestUI . activeWordElementIndex + 1 ) ;
340
- TestUI . updateActiveElement ( ) ;
340
+ await TestUI . updateActiveElement ( ) ;
341
341
void Caret . updatePosition ( ) ;
342
342
343
343
if (
@@ -363,7 +363,7 @@ async function handleSpace(): Promise<void> {
363
363
}
364
364
365
365
if ( nextTop > currentTop ) {
366
- TestUI . lineJump ( currentTop ) ;
366
+ await TestUI . lineJump ( currentTop ) ;
367
367
}
368
368
} //end of line wrap
369
369
@@ -461,32 +461,32 @@ function isCharCorrect(char: string, charIndex: number): boolean {
461
461
return false ;
462
462
}
463
463
464
- function handleChar (
464
+ async function handleChar (
465
465
char : string ,
466
466
charIndex : number ,
467
467
realInputValue ?: string
468
- ) : void {
468
+ ) : Promise < void > {
469
469
if ( TestUI . resultCalculating || TestUI . resultVisible ) {
470
470
return ;
471
471
}
472
472
473
473
if ( char === "…" && TestWords . words . getCurrent ( ) [ charIndex ] !== "…" ) {
474
474
for ( let i = 0 ; i < 3 ; i ++ ) {
475
- handleChar ( "." , charIndex + i ) ;
475
+ await handleChar ( "." , charIndex + i ) ;
476
476
}
477
477
478
478
return ;
479
479
}
480
480
481
481
if ( char === "œ" && TestWords . words . getCurrent ( ) [ charIndex ] !== "œ" ) {
482
- handleChar ( "o" , charIndex ) ;
483
- handleChar ( "e" , charIndex + 1 ) ;
482
+ await handleChar ( "o" , charIndex ) ;
483
+ await handleChar ( "e" , charIndex + 1 ) ;
484
484
return ;
485
485
}
486
486
487
487
if ( char === "æ" && TestWords . words . getCurrent ( ) [ charIndex ] !== "æ" ) {
488
- handleChar ( "a" , charIndex ) ;
489
- handleChar ( "e" , charIndex + 1 ) ;
488
+ await handleChar ( "a" , charIndex ) ;
489
+ await handleChar ( "e" , charIndex + 1 ) ;
490
490
return ;
491
491
}
492
492
@@ -745,7 +745,7 @@ function handleChar(
745
745
TestInput . input . current . length > 1
746
746
) {
747
747
if ( Config . mode === "zen" ) {
748
- if ( ! Config . showAllLines ) TestUI . lineJump ( activeWordTopBeforeJump ) ;
748
+ if ( ! Config . showAllLines ) await TestUI . lineJump ( activeWordTopBeforeJump ) ;
749
749
} else {
750
750
TestInput . input . current = TestInput . input . current . slice ( 0 , - 1 ) ;
751
751
void TestUI . updateActiveWordLetters ( ) ;
@@ -785,7 +785,10 @@ function handleChar(
785
785
}
786
786
}
787
787
788
- function handleTab ( event : JQuery . KeyDownEvent , popupVisible : boolean ) : void {
788
+ async function handleTab (
789
+ event : JQuery . KeyDownEvent ,
790
+ popupVisible : boolean
791
+ ) : Promise < void > {
789
792
if ( TestUI . resultCalculating ) {
790
793
event . preventDefault ( ) ;
791
794
return ;
@@ -813,7 +816,7 @@ function handleTab(event: JQuery.KeyDownEvent, popupVisible: boolean): void {
813
816
event . preventDefault ( ) ;
814
817
// insert tab character if needed (only during the test)
815
818
if ( ! TestUI . resultVisible && shouldInsertTabCharacter ) {
816
- handleChar ( "\t" , TestInput . input . current . length ) ;
819
+ await handleChar ( "\t" , TestInput . input . current . length ) ;
817
820
setWordsInput ( " " + TestInput . input . current ) ;
818
821
return ;
819
822
}
@@ -840,7 +843,7 @@ function handleTab(event: JQuery.KeyDownEvent, popupVisible: boolean): void {
840
843
// insert tab character if needed (only during the test)
841
844
if ( ! TestUI . resultVisible && shouldInsertTabCharacter ) {
842
845
event . preventDefault ( ) ;
843
- handleChar ( "\t" , TestInput . input . current . length ) ;
846
+ await handleChar ( "\t" , TestInput . input . current . length ) ;
844
847
setWordsInput ( " " + TestInput . input . current ) ;
845
848
return ;
846
849
}
@@ -859,7 +862,7 @@ function handleTab(event: JQuery.KeyDownEvent, popupVisible: boolean): void {
859
862
// insert tab character if needed
860
863
if ( shouldInsertTabCharacter ) {
861
864
event . preventDefault ( ) ;
862
- handleChar ( "\t" , TestInput . input . current . length ) ;
865
+ await handleChar ( "\t" , TestInput . input . current . length ) ;
863
866
setWordsInput ( " " + TestInput . input . current ) ;
864
867
return ;
865
868
}
@@ -936,7 +939,7 @@ $(document).on("keydown", async (event) => {
936
939
937
940
//tab
938
941
if ( event . key === "Tab" ) {
939
- handleTab ( event , popupVisible ) ;
942
+ await handleTab ( event , popupVisible ) ;
940
943
}
941
944
942
945
//esc
@@ -1050,7 +1053,7 @@ $(document).on("keydown", async (event) => {
1050
1053
Monkey . type ( ) ;
1051
1054
1052
1055
if ( event . key === "Backspace" && TestInput . input . current . length === 0 ) {
1053
- backspaceToPrevious ( ) ;
1056
+ await backspaceToPrevious ( ) ;
1054
1057
if ( TestInput . input . current ) {
1055
1058
setWordsInput ( " " + TestInput . input . current + " " ) ;
1056
1059
}
@@ -1088,7 +1091,7 @@ $(document).on("keydown", async (event) => {
1088
1091
}
1089
1092
}
1090
1093
} else {
1091
- handleChar ( "\n" , TestInput . input . current . length ) ;
1094
+ await handleChar ( "\n" , TestInput . input . current . length ) ;
1092
1095
setWordsInput ( " " + TestInput . input . current ) ;
1093
1096
}
1094
1097
}
@@ -1141,7 +1144,7 @@ $(document).on("keydown", async (event) => {
1141
1144
await funbox . functions . preventDefaultEvent ( event as JQuery . KeyDownEvent )
1142
1145
) {
1143
1146
event . preventDefault ( ) ;
1144
- handleChar ( event . key , TestInput . input . current . length ) ;
1147
+ await handleChar ( event . key , TestInput . input . current . length ) ;
1145
1148
updateUI ( ) ;
1146
1149
setWordsInput ( " " + TestInput . input . current ) ;
1147
1150
}
@@ -1157,7 +1160,7 @@ $(document).on("keydown", async (event) => {
1157
1160
const char : string | null = await LayoutEmulator . getCharFromEvent ( event ) ;
1158
1161
if ( char !== null ) {
1159
1162
event . preventDefault ( ) ;
1160
- handleChar ( char , TestInput . input . current . length ) ;
1163
+ await handleChar ( char , TestInput . input . current . length ) ;
1161
1164
updateUI ( ) ;
1162
1165
setWordsInput ( " " + TestInput . input . current ) ;
1163
1166
}
@@ -1243,7 +1246,7 @@ $("#wordsInput").on("beforeinput", (event) => {
1243
1246
}
1244
1247
} ) ;
1245
1248
1246
- $ ( "#wordsInput" ) . on ( "input" , ( event ) => {
1249
+ $ ( "#wordsInput" ) . on ( "input" , async ( event ) => {
1247
1250
if ( ! event . originalEvent ?. isTrusted || TestUI . testRestarting ) {
1248
1251
( event . target as HTMLInputElement ) . value = " " ;
1249
1252
return ;
@@ -1312,7 +1315,7 @@ $("#wordsInput").on("input", (event) => {
1312
1315
1313
1316
if ( realInputValue . length === 0 && currTestInput . length === 0 ) {
1314
1317
// fallback for when no Backspace keydown event (mobile)
1315
- backspaceToPrevious ( ) ;
1318
+ await backspaceToPrevious ( ) ;
1316
1319
} else if ( inputValue . length < currTestInput . length ) {
1317
1320
if ( containsChinese ) {
1318
1321
if (
@@ -1332,7 +1335,11 @@ $("#wordsInput").on("input", (event) => {
1332
1335
iOffset = inputValue . indexOf ( " " ) + 1 ;
1333
1336
}
1334
1337
for ( let i = diffStart ; i < inputValue . length ; i ++ ) {
1335
- handleChar ( inputValue [ i ] as string , i - iOffset , realInputValue ) ;
1338
+ await handleChar (
1339
+ inputValue [ i ] as string ,
1340
+ i - iOffset ,
1341
+ realInputValue
1342
+ ) ;
1336
1343
}
1337
1344
}
1338
1345
} else if ( containsKorean ) {
@@ -1369,7 +1376,7 @@ $("#wordsInput").on("input", (event) => {
1369
1376
}
1370
1377
for ( let i = diffStart ; i < inputValue . length ; i ++ ) {
1371
1378
// passing realInput to allow for correct Korean character compilation
1372
- handleChar ( inputValue [ i ] as string , i - iOffset , realInputValue ) ;
1379
+ await handleChar ( inputValue [ i ] as string , i - iOffset , realInputValue ) ;
1373
1380
}
1374
1381
}
1375
1382
0 commit comments