diff --git a/src/commands/helpers.ts b/src/commands/helpers.ts index 91116d7..5dc4eb9 100644 --- a/src/commands/helpers.ts +++ b/src/commands/helpers.ts @@ -6,6 +6,17 @@ import { type PaneType, } from "obsidian"; +declare module "obsidian" { + // eslint-disable-next-line @typescript-eslint/no-unused-vars -- cannot declare otherwise + interface FuzzySuggestModal { + chooser?: { + useSelectedItem: (evt: KeyboardEvent) => boolean; + moveDown: (count: number) => void; + moveUp: (count: number) => void; + }; + } +} + export class JumpModal extends FuzzySuggestModal { items: Map; onSelect: (value: T, modEvent: boolean | PaneType) => void; @@ -33,6 +44,21 @@ export class JumpModal extends FuzzySuggestModal { return false; }); + // navigate up/down with Tab and Shift+Tab + this.scope.register([], "Tab", (): void => { + document.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowDown" })); + }); + this.scope.register(["Shift"], "Tab", (): void => { + document.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowUp" })); + }); + instructions.concat([{ + command: "↹ ", + purpose: "Down", + },{ + command: "↹ ", + purpose: "Down", + }]) + this.setInstructions(instructions); }