Skip to content

Commit 6a8b0cf

Browse files
committed
fix: disabled keybinds when typing notes
1 parent 1cf5eb3 commit 6a8b0cf

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.changeset/clever-snakes-fix.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gregmat-buddy": patch
3+
---
4+
5+
fixed keybinds active while typing notes

src/entrypoints/gregmat.content/vocab-mountain.ts

+10
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ const keys = {
1616
right: eventGenerator("ArrowRight"),
1717
} as const;
1818

19+
function isNotesFocused() {
20+
const note = document.getElementById("note");
21+
22+
return document.activeElement == note;
23+
}
24+
1925
function registerKeybinds() {
2026
document.addEventListener("keydown", (ev) => {
2127
let key = null;
2228

29+
if (isNotesFocused()) return;
30+
2331
switch (ev.key) {
2432
case String(ev.key.match(/^j$/i)):
2533
key = keys.down;
@@ -46,6 +54,8 @@ function registerKeybinds() {
4654
document.addEventListener("keyup", (ev) => {
4755
if (!ev.key.match(/^[grf]$/i)) return;
4856

57+
if (isNotesFocused()) return;
58+
4959
document.body.dispatchEvent(keys.down);
5060
});
5161
}

0 commit comments

Comments
 (0)