}
const browserUI = BrowserUI();
+const scrollIncrement = 60;
enum InputState {
Root,
S,
if (event.key == "Escape") return browserUI.completeEdit(event, CommitOrAbort.Abort);
}
} else {
- if (event.ctrlKey) return; // eg: Don't redo when user refreshes the page with ctrl-R
if (inputState === InputState.Root) {
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(inputCount ?? 1);
- if (event.key == "K") return browserUI.moveTask(-(inputCount ?? 1));
- if (event.key == "G") return browserUI.jumpCursor(inputCount ?? MAX_SAFE_INTEGER);
- 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 (event.ctrlKey) {
+ if (event.key == "e") return window.scrollBy(0, (inputCount ?? 1) * scrollIncrement);
+ if (event.key == "y") return window.scrollBy(0, (inputCount ?? 1) * -scrollIncrement);
+ } else {
+ 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(inputCount ?? 1);
+ if (event.key == "K") return browserUI.moveTask(-(inputCount ?? 1));
+ if (event.key == "G") return browserUI.jumpCursor(inputCount ?? MAX_SAFE_INTEGER);
+ 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;
}