Liresol / anki-custom-shortcuts

Custom Keyboard Shortcuts for Anki 2.1
MIT License
60 stars 14 forks source link

Cannot map 'u' to undo. #209

Open Yi-Zhou opened 1 year ago

Yi-Zhou commented 1 year ago

I am using Anki 2.1.65 on a MacBook Air 2020 (M1). The add-on won't map 'u' to undo.

I have attempted to restart Anki, and I am able to map the number 5 and Qt.Key_Up to the "undo" function. However, the key binding does not work for the 'u' key. I have also tried disabling all other add-ons and restarting, but the issue persists.

I have observed some strange behavior which I have captured in this videohttps://www.loom.com/share/24ed163edfac4ed38fa19adb28c5a3d0?sid=77f20116-dfec-49b1-a5b4-b6ac56a55bc0. In the video, you can observe my attempts to press the 'u' key. Initially, it shows "nothing to undo," but after I have reviewed at least one card, there is no response when pressing the 'u' key.

It's worth noting that I have successfully bound the number 5 and Qt.Key_Up keys to the "undo" function. These keys do work.

Do you have any ideas about what might be happening here or how I can debug this issue? Below are my complete settings if it helps:

{
    "editor _duplicates": {},
    "editor _extras": {
        "paste custom text": "<nop>"
    },
    "editor _pastes": {},
    "editor add card close window": "<default>",
    "editor add media": "F3",
    "editor block indent": "<nop>",
    "editor block outdent": "<nop>",
    "editor bold": "Ctrl+B",
    "editor card layout": "Ctrl+L",
    "editor change col": "F8",
    "editor change deck": "<nop>",
    "editor change note type": "Ctrl+N",
    "editor cloze": "Ctrl+Shift+C",
    "editor cloze alt": "Ctrl+Shift+Alt+C",
    "editor cloze forced increment": "<nop>",
    "editor cloze no increment": "<nop>",
    "editor confirm add card": "Ctrl+Return",
    "editor focus tags": "Ctrl+Shift+T",
    "editor foreground": "F7",
    "editor html edit": "Ctrl+Shift+X",
    "editor insert latex": "Ctrl+T, T",
    "editor insert latex equation": "Ctrl+T, E",
    "editor insert latex math environment": "Ctrl+T, M",
    "editor insert mathjax block": "Ctrl+M, E",
    "editor insert mathjax chemistry": "Ctrl+M, C",
    "editor insert mathjax inline": "Ctrl+M, M",
    "editor italic": "Ctrl+I",
    "editor list insert ordered": "<nop>",
    "editor list insert unordered": "<nop>",
    "editor record sound": "F5",
    "editor remove format": "Ctrl+R",
    "editor subscript": "Ctrl+=",
    "editor superscript": "Ctrl++",
    "editor toggle sticky all": "Shift+F9",
    "editor toggle sticky current": "F9",
    "editor underline": "Ctrl+U",
    "m_toolbox _duplicates": {
        "m_toolbox undo+++ 5": "5",
        "m_toolbox undo+++ up": "Qt.Key_Up",
        "m_toolbox undo+++ uu": "U"
    },
    "m_toolbox addons": "Ctrl+Shift+A",
    "m_toolbox create filtered deck": "F",
    "m_toolbox export": "Ctrl+E",
    "m_toolbox import": "Ctrl+Shift+I",
    "m_toolbox preferences": "Ctrl+P",
    "m_toolbox quit": "Ctrl+Q",
    "m_toolbox see documentation": "F1",
    "m_toolbox study": "/",
    "m_toolbox switch profile": "Ctrl+Shift+P",
    "m_toolbox undo": "Ctrl+Z",
    "main add": "A",
    "main browse": "B",
    "main debug": "Ctrl+:",
    "main deckbrowser": "D",
    "main stats": "T",
    "main study": "S",
    "main sync": "Y",
    "reviewer _duplicates": {
        "reviewer choice 1+++ a": "Qt.Key_Left",
        "reviewer choice 1+++ e": "j",
        "reviewer choice 2+++ b": "Qt.Key_Down",
        "reviewer choice 2+++ f": "k",
        "reviewer choice 4+++ h": ";",
        "reviewer flip card 3+++ 3": "3",
        "reviewer flip card 3+++ l": "l",
        "reviewer flip card 3+++ right": "Qt.Key_Right",
        "reviewer replay audio+++ 0": "0",
        "reviewer replay audio+++ n": "n"
    },
    "reviewer bury card": "-",
    "reviewer bury note": "=",
    "reviewer card info": "I",
    "reviewer choice 1": "1",
    "reviewer choice 2": "2",
    "reviewer choice 3": "`",
    "reviewer choice 4": "4",
    "reviewer delete note": "Ctrl+Delete",
    "reviewer edit current": "E",
    "reviewer flip card 1": " ",
    "reviewer flip card 2": "Qt.Key_Return",
    "reviewer flip card 3": "Qt.Key_Enter",
    "reviewer mark card": "*",
    "reviewer more options": "M",
    "reviewer options menu": "o",
    "reviewer pause audio": "6",
    "reviewer play recorded voice": "v",
    "reviewer previous card info": "Alt+I",
    "reviewer record voice": "Shift+v",
    "reviewer replay audio 1": "r",
    "reviewer replay audio 2": "F5",
    "reviewer seek backward": "7",
    "reviewer seek forward": "8",
    "reviewer set due date": "Ctrl+Shift+D",
    "reviewer set flag 0": "Ctrl+0",
    "reviewer set flag 1": "Ctrl+1",
    "reviewer set flag 2": "Ctrl+2",
    "reviewer set flag 3": "Ctrl+3",
    "reviewer set flag 4": "Ctrl+4",
    "reviewer set flag 5": "Ctrl+5",
    "reviewer set flag 6": "Ctrl+6",
    "reviewer set flag 7": "Ctrl+7",
    "reviewer suspend card": "@",
    "reviewer suspend note": "!",
    "window_browser _filters": {
        "_concat": {},
        "_orConcat": {}
    },
    "window_browser add note": "Ctrl+E",
    "window_browser add tag": "Ctrl+Shift+A",
    "window_browser change deck": "Ctrl+D",
    "window_browser change note type": "Ctrl+Shift+M",
    "window_browser clear unused tags": "<nop>",
    "window_browser close": "Ctrl+W",
    "window_browser delete": "Ctrl+Del",
    "window_browser filter": "Ctrl+Shift+F",
    "window_browser find": "Ctrl+F",
    "window_browser find and replace": "Ctrl+Alt+F",
    "window_browser find duplicates": "<nop>",
    "window_browser first card": "Home",
    "window_browser flag_blue": "Ctrl+4",
    "window_browser flag_green": "Ctrl+3",
    "window_browser flag_orange": "Ctrl+2",
    "window_browser flag_red": "Ctrl+1",
    "window_browser forget card": "Ctrl+Alt+N",
    "window_browser goto card list": "Ctrl+Shift+L",
    "window_browser goto next note": "Ctrl+N",
    "window_browser goto note": "Ctrl+Shift+N",
    "window_browser goto previous note": "Ctrl+P",
    "window_browser goto sidebar": "Ctrl+Shift+R",
    "window_browser guide": "F1",
    "window_browser info": "Ctrl+Shift+I",
    "window_browser invert selection": "Ctrl+Alt+S",
    "window_browser last card": "End",
    "window_browser manage note types": "<nop>",
    "window_browser preview": "Ctrl+Shift+P",
    "window_browser remove current filter": "<nop>",
    "window_browser remove tag": "Ctrl+Alt+Shift+A",
    "window_browser reposition": "Ctrl+Shift+S",
    "window_browser reschedule": "Ctrl+Shift+D",
    "window_browser save current filter": "<nop>",
    "window_browser select all": "Ctrl+Alt+A",
    "window_browser select notes": "<nop>",
    "window_browser sidebar search": "Alt+1",
    "window_browser sidebar select": "Alt+2",
    "window_browser suspend": "Ctrl+J",
    "window_browser toggle mark": "Ctrl+K",
    "window_browser undo": "Ctrl+Alt+Z",
    "Ω custom paste end style": "n",
    "Ω custom paste extra texts": {},
    "Ω custom paste text": "",
    "Ω enable conflict warning": "y",
    "Ω enable editor": "y",
    "Ω enable m_toolbox": "y",
    "Ω enable main": "y",
    "Ω enable reviewer": "y",
    "Ω enable window_browser": "y"
}

Thank you!

Daedalus359 commented 1 year ago

It seems like "u" is hard-coded as an undo key in Anki itself, as of May 18: https://forums.ankiweb.net/t/change-new-shortcuts-in-2-1-63/30405 Maybe looking up Anki change notes for the versions in those forum posts will help you understand the behavior you are seeing.

The documentation on the extension's config page includes the following:

"m_toolbox _duplicates": Takes functions and binds them to new shortcuts.

This object takes inputs of the form "(function keyword)":"(shortcut)", separated by commas. (e.g. {"m_toolbox undo":"u","m_toolbox study":"9"})

It looks like you're trying to set this functionality with the line "m_toolbox undo+++ uu": "U". It might be worth trying to temporarily remove the additional shortcuts you set for this function, and see what happens when you use the exact form suggested in the documentation snippet above. If that doesn't do what you want, then the docs probably have an error.

Also, just making sure you noticed: you have the shortcut bound to "U", not "u".

I'm actually trying to get the default shortcut behavior for "u" disabled, but it seems like that is not currently supported. I'm very new to this extension, so apologies if I said something incorrect or obvious. This is all stuff I am just learning today. Hopefully something was helpful.