Make "ctrl" + "+"/"-" zoom in/out

Hello. it disappointed me that when i tried to use ctrl and + or - combination anki didn’t respond by zooming my card, but you can do that on browsers, it’s awkward for me to use mouse, i’d like to be able to zoom on just the keyboard, please implement this little shortcut in the next update, if it’s possible. yoroshiku onegaishimasu.

3 Likes

This addon can help you

https://ankiweb.net/shared/info/1923741581

3 Likes

Thanks for the mention, all the Zoom add-ons were broken so I fixed it.

I think the Ctrl + + and Ctrl + - not working is a bug in PyQt that Anki is using, maybe a similar problem was reported in PyQt. (I forgot the URL)

The Ctrl + + works on the old Anki, but not on the new Anki, so I have changed it to Ctrl + Shift + + and Ctrl + Shift + + in the fixed add-on.

Basically there is no workaround for the PyQt bug, it may be possible to solve this problem by using JavaScript, but I have not tried it.

You can change the shortcut key to any key you like in the options. (Except Ctrl + + )

  • tools → Zoom 24

Anki doesn’t define the shortcuts by default, since they conflict, and don’t seem to work on certain keyboard layouts: View menu by RumovZ · Pull Request #1668 · ankitects/anki · GitHub

1 Like

Shigeyuki, I think I discovered the zoom problem, if you put ctrl+= it will work like ctrl+

I tested it by doing the code below

from aqt import mw
from aqt.qt import QShortcut, QKeySequence

def zoom_in():
    current_zoom = mw.web.zoomFactor()
    new_zoom = min(current_zoom + 0.1, 3.0)
    mw.web.setZoomFactor(new_zoom)

def zoom_out():
    current_zoom = mw.web.zoomFactor()
    new_zoom = max(current_zoom - 0.1, 0.1)
    mw.web.setZoomFactor(new_zoom)

def setup_shortcuts():
    zoom_in_shortcut = QShortcut(QKeySequence("Ctrl+="), mw)
    zoom_in_shortcut.activated.connect(zoom_in)

    zoom_out_shortcut = QShortcut(QKeySequence("Ctrl+-"), mw)
    zoom_out_shortcut.activated.connect(zoom_out)

setup_shortcuts()

1 Like

Hi, thanks for reporting the problem.
The shortcut key problem is maybe due to PyQt and is difficult to fix, so I recommend customizing it and using different keys.