From bc7996fe80c54f0a7a45e2153a27df466434938c Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 26 Jan 2022 13:25:47 -0800 Subject: [PATCH] Control-enter to make new tasks top-priority --- vopamoi.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vopamoi.ts b/vopamoi.ts index ba5ae85..fa55920 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -133,11 +133,14 @@ const UI = { }; const BrowserUI = { - addTask: function () { + addTask: function (event: KeyboardEvent) { const input = document.getElementById("taskName"); if (input.value) { const task = UI.addTask(input.value); input.value = ""; + if (event.getModifierState("Control")) { + this.setPriority(task, null, document.getElementsByClassName("task")[0]); + } } }, @@ -147,7 +150,7 @@ const BrowserUI = { return UI.destroyTask(createTimestamp!); }, - focusTaskNameInput: function (event: any) { + focusTaskNameInput: function (event: Event) { document.getElementById("taskName")!.focus(); event.preventDefault(); }, @@ -215,7 +218,7 @@ const BrowserUI = { function handleKey(event: any) { if (event.target.tagName === "INPUT") { - if (event.key == "Enter") return BrowserUI.addTask(); + if (event.key == "Enter") return BrowserUI.addTask(event); } else { if (event.key == "j") return BrowserUI.moveCursor(1); if (event.key == "k") return BrowserUI.moveCursor(-1); -- 2.44.1