From 06ee32a10fa00f28eaae8a6f7e948b422e1861cd Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 25 Jan 2022 22:24:05 -0800 Subject: [PATCH] Keep handleKey lean --- vopamoi.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/vopamoi.ts b/vopamoi.ts index 654a7a8..ab58d6d 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -75,14 +75,16 @@ const UI = { }, }; +function focusTaskNameInput(event: any) { + document.getElementById("taskName")!.focus(); + event.preventDefault(); +} + function handleKey(event: any) { if (event.target.tagName !== "INPUT") { - if (event.key == "j") Model.moveCursor(1); - if (event.key == "k") Model.moveCursor(-1); - if (event.key == "c") { - document.getElementById("taskName")!.focus(); - event.preventDefault(); - } + if (event.key == "j") return Model.moveCursor(1); + if (event.key == "k") return Model.moveCursor(-1); + if (event.key == "c") return focusTaskNameInput(event); } } -- 2.44.1