“View on Ankihub” shortcut

Hello!

I was wondering if there is a way to assign a hotkey/shortcut for “view on ankihub,” both on mobile and desktop. I searched through the ankihub community and found this thread from Dec. ‘23 on the topic.

I was wondering:

  • Has this feature been added? I couldn’t find it.
  • Is there a way for me to JavaScript it myself somehow?

It really would make my life a whole lot easier.

Thanks everyone!

It’s not been added yet. You can try modifying the add-on’s sources as follows to add a shortcut:

  1. Open the gui/editor.py file and go to line 102.
  2. Change the following code:
    view_on_ankihub_button = editor.addButton(
        icon=None,
        cmd=VIEW_NOTE_BTN_ID,
        func=_on_view_note_button_press,
        label="View on AnkiHub",
        id=VIEW_NOTE_BTN_ID,
        disables=False,
    )

To add a keys argument like this:

    view_on_ankihub_button = editor.addButton(
        icon=None,
        cmd=VIEW_NOTE_BTN_ID,
        func=_on_view_note_button_press,
        label="View on AnkiHub",
        id=VIEW_NOTE_BTN_ID,
        disables=False,
        keys="YOUR_SHORTCUT"
    )

The shortcut shouldn’t be already assigned to some other function in the editor, otherwise, it may not work.

Note that any changes to the source code will be overwritten after add-on updates.


I’m not seeing a gui/editor.py file - where might I find it in the addon files?
Thank you for your help!

It’s editor.py inside the gui folder

Awesome, thank you!

I’m not sure what the overlap here is, but is there a way to make it one of the possible dropdown options for the AnkiMobile User Actions?

Thanks again!

And I have (hopefully) only one more question: in the
keys=“YOUR_SHORTCUT”
line, I’m assuming that I should put something along the lines of
keys=“W”
or something like that? If I used the above example, will hitting the “W” key on my keyboard cause my computer to open the ankihub page for that note? I ask because doing that doesn’t seem to have accomplished this task.

Thanks!

I assumed you’re asking about the View on AnkiHub button in the editor, rather than the reviewer. Changing the shortcut there is more involved. Check the gui/reviewer.py file. You have to know some basic JavaScript to add a keydown event listener to the button.

The reviewer button is only shown on desktop. For mobile, you have to modify the card template (a similar button is included there).

It’s possible, but it involves some coding.

Anybody figured out “View on Ankihub” shortcut in reviewer on desktop? If so, kindly share the code.