From: Scott Worley Date: Wed, 26 Jan 2022 21:25:47 +0000 (-0800) Subject: Control-enter to make new tasks top-priority X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/bc7996fe80c54f0a7a45e2153a27df466434938c?hp=6d01c40696f0612a6352f21320f417ccf528ab40 Control-enter to make new tasks top-priority --- 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);