From a26b1f4b541b3cfad00999530e8e4c9e613db806 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 26 Jan 2022 13:11:09 -0800 Subject: [PATCH] Initiate task creation with Enter key rather than form submit This will let us detect modifiers on the keystroke. --- index.html | 4 +--- vopamoi.ts | 14 ++++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index 91908e3..ac8cb53 100644 --- a/index.html +++ b/index.html @@ -4,9 +4,7 @@ -
- -
+
diff --git a/vopamoi.ts b/vopamoi.ts index ab06155..fe3d491 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -132,12 +132,12 @@ const UI = { }; const BrowserUI = { - addTask: function (form: any) { - if (form.taskName.value) { - UI.addTask(form.taskName.value); - form.taskName.value = ""; + addTask: function () { + const input = document.getElementById("taskName"); + if (input.value) { + UI.addTask(input.value); + input.value = ""; } - return false; }, destroyTask: function () { @@ -213,7 +213,9 @@ const BrowserUI = { }; function handleKey(event: any) { - if (event.target.tagName !== "INPUT") { + if (event.target.tagName === "INPUT") { + if (event.key == "Enter") return BrowserUI.addTask(); + } else { if (event.key == "j") return BrowserUI.moveCursor(1); if (event.key == "k") return BrowserUI.moveCursor(-1); if (event.key == "J") return BrowserUI.moveTask(1); -- 2.44.1