Shortcuts for starting bulleted/numbered list, increasing/decreasing indent

Edit I’m dumb, just misread your request @MedBooster and thought it was about lists. Well, one could probably apply the same strategy for the indent/outdent buttons.


I’m all for natively integrating shortcuts for lists etc…
In the meantime, you can just simulate clicking these buttons via JS.

Method 1 (with your own add-on)

You could use the hook editor_will_load_note to append a little script.

Script
if (!globalThis.listShortcuts) {
    document.addEventListener("keydown", (e) => {
        if (e.altKey) {
            switch (e.key) {
                case "o": {
                    e.preventDefault()
                    document.querySelector("[title='Ordered list']").click()
                } break
                case "u": {
                    e.preventDefault()
                    document.querySelector("[title='Unordered list']").click()
                }
            }
        }
    }
    globalThis.listShortcuts = true
}

Method 2 (with keymap addon)

As @TRIAEIOU explains in this post, there are several add-ons that allow you to execute JS snippets with keyboard commands.

With an add-on like Custom editor keymap - AnkiWeb you wouldn’t need to insert that eventListener into the webview. Just bind the commands

document.querySelector("[title='Ordered list']").click()

and

document.querySelector("[title='Unordered list']").click()

to some custom shortcut.

2 Likes