mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-09 13:44:29 +08:00
storing state
binding event to words input instead of document
This commit is contained in:
parent
78e3a54b02
commit
6970fbddaa
1 changed files with 8 additions and 4 deletions
|
|
@ -2,19 +2,23 @@ import Config from "../config";
|
|||
|
||||
export let capsState = false;
|
||||
|
||||
let visible = false;
|
||||
|
||||
function show(): void {
|
||||
if ($("#capsWarning").hasClass("hidden")) {
|
||||
if (!visible) {
|
||||
$("#capsWarning").removeClass("hidden");
|
||||
visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
function hide(): void {
|
||||
if (!$("#capsWarning").hasClass("hidden")) {
|
||||
if (visible) {
|
||||
$("#capsWarning").addClass("hidden");
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
$(document).keydown(function (event) {
|
||||
$("#wordsInput").on("keydown", function (event) {
|
||||
if (
|
||||
event?.originalEvent?.getModifierState &&
|
||||
event?.originalEvent?.getModifierState("CapsLock")
|
||||
|
|
@ -33,7 +37,7 @@ $(document).keydown(function (event) {
|
|||
} catch {}
|
||||
});
|
||||
|
||||
$(document).keyup(function (event) {
|
||||
$("#wordsInput").on("keyup", function (event) {
|
||||
if (
|
||||
event?.originalEvent?.getModifierState &&
|
||||
event?.originalEvent?.getModifierState("CapsLock")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue