};
const BrowserUI = {
- 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 = "";
}
- return false;
},
destroyTask: function () {
};
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);