What I’m trying to do
I am trying to navigate pdfs effectively. I like vim , i.e. , no mouse. I know that arrow keys can be used to move one page down /up. But I want to goto page 3 or 3rd page by typing something like 3gg.
Things I have tried
I tried making a plugin with the following final build.js but found out that this.app.commands.executeCommandById(“pdf:next-page”); doesn’t work as there is no command pdf:next-page. I used AI to get till here as i dont know obisdian documentation but I know enough JS to make plugins/extensions.
import { Plugin } from "obsidian";
export default class PdfVimNavigation extends Plugin {
onload() {
this.registerDomEvent(document, "keydown", (e: KeyboardEvent) => {
const leaf = this.app.workspace.activeLeaf;
if (!leaf) return;
const view: any = leaf.view;
if (!view || view.getViewType() !== "pdf") return;
if (e.key === "k" && !e.ctrlKey) {
e.preventDefault();
this.app.commands.executeCommandById("pdf:next-page");
console.log("kcuf em k");
}
if (e.key === "j" && !e.ctrlKey) {
e.preventDefault();
this.app.commands.executeCommandById("pdf:previous-page");
console.log("kcuf em j");
}
if (e.key === "g" && e.ctrlKey) {
e.preventDefault();
this.app.commands.executeCommandById("pdf:go-to-page");
console.log("kcuf em g");
}
});
}
}