mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-10 07:36:09 +08:00
requiring shift + enter to be double tapped to bail out of a test
closes #4149
This commit is contained in:
parent
f29db00949
commit
d7bf0552de
1 changed files with 19 additions and 2 deletions
|
@ -761,6 +761,8 @@ function handleTab(event: JQuery.KeyDownEvent, popupVisible: boolean): void {
|
|||
}
|
||||
}
|
||||
|
||||
let lastBailoutAttempt = -1;
|
||||
|
||||
$(document).keydown(async (event) => {
|
||||
if (ActivePage.get() == "loading") return;
|
||||
|
||||
|
@ -874,8 +876,23 @@ $(document).keydown(async (event) => {
|
|||
CustomTextState.isCustomTextLong() ?? false
|
||||
)
|
||||
) {
|
||||
TestInput.setBailout(true);
|
||||
TestLogic.finish();
|
||||
const delay = Date.now() - lastBailoutAttempt;
|
||||
if (lastBailoutAttempt === -1 || delay > 200) {
|
||||
lastBailoutAttempt = Date.now();
|
||||
if (delay >= 5000) {
|
||||
Notifications.add(
|
||||
"Please double tap shift+enter to confirm bail out",
|
||||
0,
|
||||
{
|
||||
important: true,
|
||||
duration: 5000,
|
||||
}
|
||||
);
|
||||
}
|
||||
} else {
|
||||
TestInput.setBailout(true);
|
||||
TestLogic.finish();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
handleChar("\n", TestInput.input.current.length);
|
||||
|
|
Loading…
Add table
Reference in a new issue