From cfde9dc0bdc1283503de19e0a8a7ec02e593541b Mon Sep 17 00:00:00 2001 From: umsangdon Date: Sat, 10 Oct 2026 15:41:39 +0900 Subject: [PATCH] =?UTF-8?q?refactor(=EA=B3=B5=EC=9A=A9):=20=EB=8F=8B?= =?UTF-8?q?=EB=B3=B4=EA=B8=B0=20Z=20=ED=82=A4=20=ED=8C=90=EC=A0=95=20?= =?UTF-8?q?=E2=80=94=20=EA=B3=B5=EC=9A=A9=20key=5Fshortcut=20keyLetter=20?= =?UTF-8?q?=EB=A1=9C=20=EB=B0=94=EA=BF=88=20=C2=B7=20=EB=8F=99=EC=9E=91=20?= =?UTF-8?q?=EA=B7=B8=EB=8C=80=EB=A1=9C(218-2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01QND7Co43B24zK2P937rdxt --- resources/tester/helper_218_1_loupe.cjs | 24 ++++++++++++++++-------- ui_template/ui_template_loupe.ts | 10 ++++++---- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/resources/tester/helper_218_1_loupe.cjs b/resources/tester/helper_218_1_loupe.cjs index e09756ba8..32e247990 100644 --- a/resources/tester/helper_218_1_loupe.cjs +++ b/resources/tester/helper_218_1_loupe.cjs @@ -4,14 +4,22 @@ const fs = require("fs"); const path = require("path"); const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript")); -const file = path.join(__dirname, "..", "..", "ui_template", "ui_template_loupe.ts"); -const js = ts.transpileModule(fs.readFileSync(file, "utf8"), { - compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }, -}).outputText; -const box = { exports: {} }; -const req = (p) => (p.endsWith(".css") ? {} : require(p)); -new Function("exports", "module", "require", js)(box.exports, box, req); -const m = box.exports; +const ROOT = path.join(__dirname, "..", ".."); +function load(file) { + const js = ts.transpileModule(fs.readFileSync(file, "utf8"), { + compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }, + }).outputText; + const box = { exports: {} }; + const req = (p) => + p.endsWith(".css") + ? {} + : p.endsWith("key_shortcut") // 공용 키 판정(214-2)도 그 자리에서 트랜스파일 + ? load(path.join(ROOT, "A00_Common", "key_shortcut.ts")) + : require(p); + new Function("exports", "module", "require", js)(box.exports, box, req); + return box.exports; +} +const m = load(path.join(ROOT, "ui_template", "ui_template_loupe.ts")); // ---- 가짜 시계 · 가짜 창 ---- function fakeWindow(doc) { diff --git a/ui_template/ui_template_loupe.ts b/ui_template/ui_template_loupe.ts index 46a82b369..e4c40b572 100644 --- a/ui_template/ui_template_loupe.ts +++ b/ui_template/ui_template_loupe.ts @@ -10,6 +10,7 @@ * ========================================================================== */ import "./ui_template_loupe.css"; +import { keyLetter } from "../A00_Common/key_shortcut"; /** 원 지름(px) */ export const LOUPE_DIAMETER = 240; @@ -51,11 +52,12 @@ const KEEP_INSIDE = new Set([ "CAPTION", ]); -/** Z 키 판정 — 글자(`key`)가 아니라 자판 자리(`code`) · 한글 자판(「ㅋ」)도 같음(CAD `input-shortcut` 과 같은 원리) · Ctrl/Alt/Meta 조합은 아님 */ +/** Z 키 판정 — 공용 `keyLetter`(214-2 · 한글 자판 「ㅋ」 = 자판 자리 KeyZ) · Ctrl/Alt/Meta 조합은 아님 */ export function isLoupeKey( - evt: Pick, + evt: Pick & + Partial>, ): boolean { - return evt.code === "KeyZ" && !evt.ctrlKey && !evt.altKey && !evt.metaKey; + return keyLetter(evt) === "z" && !evt.ctrlKey && !evt.altKey && !evt.metaKey; } /** 글을 치는 자리 — 글 칸 · 고르기 칸 · contenteditable */ @@ -159,7 +161,7 @@ export function initLoupe( update(); }); on("keyup", (e) => { - if (e.code !== "KeyZ" || !key) return; + if (keyLetter(e) !== "z" || !key) return; key = false; update(); });