},
};
+enum InputState {
+ Command,
+}
+var inputState = InputState.Command;
+
function handleKey(event: any) {
if (event.target.tagName === "INPUT") {
if (event.target.id === "taskName") {
if (event.key == "Enter") return BrowserUI.completeEdit(event);
}
} 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 == "K") return BrowserUI.moveTask(-1);
- if (event.key == "n") return BrowserUI.focusTaskNameInput(event);
- if (event.key == "s") return BrowserUI.setState("someday-maybe");
- if (event.key == "w") return BrowserUI.setState("waiting");
- if (event.key == "d") return BrowserUI.setState("done");
- if (event.key == "c") return BrowserUI.setState("cancelled");
- if (event.key == "t") return BrowserUI.setState("todo");
- if (event.key == "X") return BrowserUI.setState("deleted");
- if (event.key == "u") return BrowserUI.undo();
- if (event.key == "e") return BrowserUI.beginEdit(event);
+ if (inputState === InputState.Command) {
+ 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 == "K") return BrowserUI.moveTask(-1);
+ if (event.key == "n") return BrowserUI.focusTaskNameInput(event);
+ if (event.key == "s") return BrowserUI.setState("someday-maybe");
+ if (event.key == "w") return BrowserUI.setState("waiting");
+ if (event.key == "d") return BrowserUI.setState("done");
+ if (event.key == "c") return BrowserUI.setState("cancelled");
+ if (event.key == "t") return BrowserUI.setState("todo");
+ if (event.key == "X") return BrowserUI.setState("deleted");
+ if (event.key == "u") return BrowserUI.undo();
+ if (event.key == "e") return BrowserUI.beginEdit(event);
+ }
}
}