VS,
}
var inputState = InputState.Root;
+var inputCount: number | null = null;
function handleKey(event: any) {
if (event.target.tagName === "INPUT") {
}
} else {
if (inputState === InputState.Root) {
- 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 == "T") return browserUI.makeTopPriority();
- if (event.key == "n") return browserUI.focusTaskNameInput(event);
- if (event.key == "c") return browserUI.setState("cancelled");
- if (event.key == "d") return browserUI.setState("done");
- if (event.key == "q") return browserUI.setState("todo");
- if (event.key == "s") return (inputState = InputState.S);
- if (event.key == "w") return browserUI.setState("waiting");
- if (event.key == "X") return browserUI.setState("deleted");
- if (event.key == "x") return browserUI.removeTag();
- if (event.key == "u") return browserUI.undo();
- if (event.key == "r") return browserUI.redo();
- if (event.key == "e") return browserUI.beginEdit(event);
- if (event.key == "t") return browserUI.beginTagEdit(event);
- if (event.key == "v") return (inputState = InputState.V);
+ if ("0" <= event.key && event.key <= "9") {
+ return (inputCount = (inputCount ?? 0) * 10 + parseInt(event.key));
+ }
+ try {
+ if (event.key == "j") return browserUI.moveCursor(inputCount ?? 1);
+ if (event.key == "k") return browserUI.moveCursor(-(inputCount ?? 1));
+ if (event.key == "J") return browserUI.moveTask(1);
+ if (event.key == "K") return browserUI.moveTask(-1);
+ if (event.key == "T") return browserUI.makeTopPriority();
+ if (event.key == "n") return browserUI.focusTaskNameInput(event);
+ if (event.key == "c") return browserUI.setState("cancelled");
+ if (event.key == "d") return browserUI.setState("done");
+ if (event.key == "q") return browserUI.setState("todo");
+ if (event.key == "s") return (inputState = InputState.S);
+ if (event.key == "w") return browserUI.setState("waiting");
+ if (event.key == "X") return browserUI.setState("deleted");
+ if (event.key == "x") return browserUI.removeTag();
+ if (event.key == "u") return browserUI.undo();
+ if (event.key == "r") return browserUI.redo();
+ if (event.key == "e") return browserUI.beginEdit(event);
+ if (event.key == "t") return browserUI.beginTagEdit(event);
+ if (event.key == "v") return (inputState = InputState.V);
+ } finally {
+ inputCount = null;
+ }
} else if (inputState === InputState.S) {
inputState = InputState.Root;
if (event.key == "m") return browserUI.setState("someday-maybe");