diff --git a/src/client/InputHandler.ts b/src/client/InputHandler.ts index cf70215d9..77a08b95c 100644 --- a/src/client/InputHandler.ts +++ b/src/client/InputHandler.ts @@ -290,11 +290,7 @@ export class InputHandler { }, 1); window.addEventListener("keydown", (e) => { - const target = e.target as HTMLElement | null; - const isTextInput = - target?.tagName === "INPUT" || - target?.tagName === "TEXTAREA" || - target?.isContentEditable; + const isTextInput = this.isTextInputTarget(e.target); if (isTextInput && e.code !== "Escape") { return; } @@ -340,11 +336,7 @@ export class InputHandler { } }); window.addEventListener("keyup", (e) => { - const target = e.target as HTMLElement | null; - const isTextInput = - target?.tagName === "INPUT" || - target?.tagName === "TEXTAREA" || - target?.isContentEditable; + const isTextInput = this.isTextInputTarget(e.target); if (isTextInput && !this.activeKeys.has(e.code)) { return; } @@ -599,6 +591,22 @@ export class InputHandler { }; } + private isTextInputTarget(target: EventTarget | null): boolean { + const element = target as HTMLElement | null; + if (!element) return false; + if (element.tagName === "TEXTAREA" || element.isContentEditable) { + return true; + } + if (element.tagName === "INPUT") { + const input = element as HTMLInputElement; + if (input.id === "attack-ratio" && input.type === "range") { + return false; + } + return true; + } + return false; + } + destroy() { if (this.moveInterval !== null) { clearInterval(this.moveInterval);