This will let us detect modifiers on the keystroke.
<script src="vopamoi.js" defer="true"></script>
</head>
<body onload="browserInit();">
<script src="vopamoi.js" defer="true"></script>
</head>
<body onload="browserInit();">
- <form onsubmit="return BrowserUI.addTask(this);">
- <input id="taskName" name="taskName">
- </form>
+ <input id="taskName" name="taskName">
<div id="tasks"></div>
</body>
</html>
<div id="tasks"></div>
</body>
</html>
- addTask: function (form: any) {
- if (form.taskName.value) {
- UI.addTask(form.taskName.value);
- form.taskName.value = "";
+ addTask: function () {
+ const input = <HTMLInputElement>document.getElementById("taskName");
+ if (input.value) {
+ UI.addTask(input.value);
+ input.value = "";
},
destroyTask: function () {
},
destroyTask: function () {
};
function handleKey(event: any) {
};
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);
if (event.key == "j") return BrowserUI.moveCursor(1);
if (event.key == "k") return BrowserUI.moveCursor(-1);
if (event.key == "J") return BrowserUI.moveTask(1);