From: Scott Worley Date: Wed, 26 Jan 2022 21:11:09 +0000 (-0800) Subject: Initiate task creation with Enter key rather than form submit X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/a26b1f4b541b3cfad00999530e8e4c9e613db806?ds=sidebyside Initiate task creation with Enter key rather than form submit This will let us detect modifiers on the keystroke. --- 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);