From: Scott Worley Date: Wed, 26 Jan 2022 06:24:05 +0000 (-0800) Subject: Keep handleKey lean X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/06ee32a10fa00f28eaae8a6f7e948b422e1861cd?ds=sidebyside Keep handleKey lean --- 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); } }