Hi,
I want to make a plugin that when ctrl+n is pressed it has the exact same behavior as the down arrow being pressed.
I thought the following would work, but editor.cm.dom.dispatchEvent(event); does not seem to do anything. Any help would be appreciated!
import { Plugin, Editor } from 'obsidian';
export default class CtrlNAsDownArrowPlugin extends Plugin {
async onload() {
this.addCommand({
id: 'ctrl-n-as-down-arrow',
name: 'Use Ctrl+N as Down Arrow',
hotkeys: [{ modifiers: ['Ctrl'], key: 'N' }],
editorCallback: (editor: Editor) => {
const event = new KeyboardEvent("keydown", {
key: "ArrowDown"
});
editor.cm.dom.dispatchEvent(event);
},
});
}
}