mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-20 12:36:58 +08:00
Fix persistent CapsLock message being displayed (#4339) sandihyas3s
* Fix persistent CapsLock message * using vanilla js to increase performance a tiny bit since this will happen on every keyup and keydown --------- Co-authored-by: Miodec <jack@monkeytype.com>
This commit is contained in:
parent
9904cd8c34
commit
c5c07c1285
1 changed files with 6 additions and 4 deletions
|
@ -1,24 +1,26 @@
|
|||
import Config from "../config";
|
||||
|
||||
const el = document.querySelector("#capsWarning") as HTMLElement;
|
||||
|
||||
export let capsState = false;
|
||||
|
||||
let visible = false;
|
||||
|
||||
function show(): void {
|
||||
if (!visible) {
|
||||
$("#capsWarning").removeClass("hidden");
|
||||
el?.classList.remove("hidden");
|
||||
visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
function hide(): void {
|
||||
if (visible) {
|
||||
$("#capsWarning").addClass("hidden");
|
||||
el?.classList.add("hidden");
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
$("#wordsInput").on("keydown", function (event) {
|
||||
$(document).on("keydown", function (event) {
|
||||
if (
|
||||
event?.originalEvent?.getModifierState &&
|
||||
event?.originalEvent?.getModifierState("CapsLock")
|
||||
|
@ -37,7 +39,7 @@ $("#wordsInput").on("keydown", function (event) {
|
|||
} catch {}
|
||||
});
|
||||
|
||||
$("#wordsInput").on("keyup", function (event) {
|
||||
$(document).on("keyup", function (event) {
|
||||
if (
|
||||
event?.originalEvent?.getModifierState &&
|
||||
event?.originalEvent?.getModifierState("CapsLock")
|
||||
|
|
Loading…
Add table
Reference in a new issue