Skip to content

Accept the zoom in hotkey when shift is held - #1268

Open
karpovantonme wants to merge 1 commit into
GyulyVGC:mainfrom
karpovantonme:fix/zoom-in-hotkey
Open

Accept the zoom in hotkey when shift is held#1268
karpovantonme wants to merge 1 commit into
GyulyVGC:mainfrom
karpovantonme:fix/zoom-in-hotkey

Conversation

@karpovantonme

Copy link
Copy Markdown
Contributor

Problem

ctrl + + does not zoom in on layouts where + is typed as shift + =. That covers US and UK ANSI and most others. On layouts where + has its own key (Italian, German) it works, which is probably why it went unnoticed.

The subscription in src/gui/sniffer.rs matches the whole modifier set by equality:

Keyboard(Event::KeyPressed { key, modifiers, .. }) => match modifiers {
    Modifiers::COMMAND => match key.as_ref() {
        ...
        Key::Character("-") => Some(Message::ScaleFactorShortcut(false)),
        Key::Character("+") => Some(Message::ScaleFactorShortcut(true)),

Modifiers is a bitflags struct, so Modifiers::COMMAND as a pattern means "command and nothing else". To produce the logical key + the user has to hold shift, and iced_winit::conversion::modifiers passes shift straight through:

result.set(keyboard::Modifiers::SHIFT, modifiers.shift_key());

So the event arrives with COMMAND | SHIFT, matches neither Modifiers::COMMAND nor Modifiers::SHIFT, and falls into the catch-all. Zoom out is unaffected because - needs no shift, which is why only one half of the shortcut is broken.

The shortcut came from #554, where it was asked for as an accessibility feature, so it seemed worth fixing properly.

Change

  • accept command + shift + +
  • accept = as a zoom in key too, without shift. That is what browsers do, and it gives people a shift-free way in
  • the key mapping moves into hotkey_message(), so it can be tested. Behaviour outside the zoom keys is unchanged, I kept the match arms in the same order

Checks

  • cargo test - 178 passed, 0 failed
  • cargo fmt --check - clean
  • cargo clippy --all-targets - 57 warnings before the change and 57 after
  • test_zoom_hotkeys fails on main with the fix reverted and passes with it, so it guards the actual bug

If you would rather keep the subscription as it was, the one-line version is to add "=" next to "+" in the existing arm. That fixes the shift-free path but leaves shift + = dead. Happy to cut it down if you prefer.

On most keyboard layouts '+' is typed as shift + '=', so the key press
reaches the app with shift among the modifiers. The subscription matched
the modifier set by equality, so ctrl + '+' fell through to the catch-all
and no zoom happened. ctrl + '-' was unaffected since '-' needs no shift.

Accept '=' as a zoom in key too, the way browsers do, and handle the
command + shift combination. The hotkey mapping moves into its own
function so it can be covered by tests.
@GyulyVGC GyulyVGC added the bug Something isn't working label Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants