Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctrl is reported as not pressed when combining Ctrl+Altgr on Windows #3012

Open
fredizzimo opened this issue Aug 6, 2023 · 3 comments
Open

Comments

@fredizzimo
Copy link

On Windows, when pressing a key in combination with altgr for example alt-gr+e, which produces , the CTRL state is not reported correctly. Here's the log from WindowEvent::KeyboardEvent, and WindowEvent::ModifiersChanged

Modifiers { state: ModifiersState(CONTROL), pressed_mods: ModifiersKeys(0x0) }
KeyEvent {
    physical_key: ControlLeft,
    logical_key: Control,
    text: None,
    location: Left,
    state: Pressed,
    repeat: false,
    platform_specific: KeyEventExtra {
        text_with_all_modifers: None,
        key_without_modifiers: Control,
    },
}
Modifiers { state: ModifiersState(0x0), pressed_mods: ModifiersKeys(0x0) }
KeyEvent {
    physical_key: AltRight,
    logical_key: AltGraph,
    text: None,
    location: Right,
    state: Pressed,
    repeat: false,
    platform_specific: KeyEventExtra {
        text_with_all_modifers: None,
        key_without_modifiers: AltGraph,
    },
}
KeyEvent {
    physical_key: AltRight,
    logical_key: AltGraph,
    text: None,
    location: Right,
    state: Pressed,
    repeat: true,
    platform_specific: KeyEventExtra {
        text_with_all_modifers: None,
        key_without_modifiers: AltGraph,
    },
}
KeyEvent {
    physical_key: AltRight,
    logical_key: AltGraph,
    text: None,
    location: Right,
    state: Pressed,
    repeat: true,
    platform_specific: KeyEventExtra {
        text_with_all_modifers: None,
        key_without_modifiers: AltGraph,
    },
}
KeyEvent {
    physical_key: AltRight,
    logical_key: AltGraph,
    text: None,
    location: Right,
    state: Pressed,
    repeat: true,
    platform_specific: KeyEventExtra {
        text_with_all_modifers: None,
        key_without_modifiers: AltGraph,
    },
}
KeyEvent {
    physical_key: AltRight,
    logical_key: AltGraph,
    text: None,
    location: Right,
    state: Pressed,
    repeat: true,
    platform_specific: KeyEventExtra {
        text_with_all_modifers: None,
        key_without_modifiers: AltGraph,
    },
}
KeyEvent {
    physical_key: KeyE,
    logical_key: Character(
        "€",
    ),
    text: Some(
        "€",
    ),
    location: Standard,
    state: Pressed,
    repeat: false,
    platform_specific: KeyEventExtra {
        text_with_all_modifers: Some(
            "€",
        ),
        key_without_modifiers: Character(
            "e",
        ),
    },
}
KeyEvent {
    physical_key: KeyE,
    logical_key: Character(
        "€",
    ),
    text: None,
    location: Standard,
    state: Released,
    repeat: false,
    platform_specific: KeyEventExtra {
        text_with_all_modifers: None,
        key_without_modifiers: Character(
            "e",
        ),
    },
}
Modifiers { state: ModifiersState(CONTROL), pressed_mods: ModifiersKeys(0x0) }
KeyEvent {
    physical_key: AltRight,
    logical_key: AltGraph,
    text: None,
    location: Right,
    state: Released,
    repeat: false,
    platform_specific: KeyEventExtra {
        text_with_all_modifers: None,
        key_without_modifiers: AltGraph,
    },
}
Modifiers { state: ModifiersState(0x0), pressed_mods: ModifiersKeys(0x0) }
KeyEvent {
    physical_key: ControlLeft,
    logical_key: Control,
    text: None,
    location: Left,
    state: Released,
    repeat: false,
    platform_specific: KeyEventExtra {
        text_with_all_modifers: None,
        key_without_modifiers: Control,
    },
}

As soon as AltGraph is pressed Modifiers::state stops reporting Control, and only starts reporting it again when AltGr is released. Therefore, it's impossible to determine that control is held down using the modifiers state alone.

Note that there's also another, not as critical bug shown in the logs, AltGraph is repeated, although I don't think there should be a key repeat on that since it's a modifier, I'm not even sure if it makes sense to report it as a key press at all, rather than a modifier state.

This was reproduced using Neovide and Winit 0.29.0-beta.0

I think a similar issue was reported by @dhardy here in this comment #2898 (comment)

@fredizzimo
Copy link
Author

This is probably some side effect of trying to deal with the fact that in Windows, alt gr and ctrl+alt are the same.

@fredizzimo fredizzimo changed the title Ctrl is reported as not pressed when combining ctrl+altgr on Windows Ctrl is reported as not pressed when combining Ctrl+Altgr on Windows Aug 6, 2023
@fredizzimo
Copy link
Author

This is probably also related #2945

@fredizzimo
Copy link
Author

I just realized that this is more critical than what it seems. I did not think of it at first, but this breaks the default mapping <C-\><C-N>, which is used to go to the normal mode of the built-in terminal of Neovim on my Swedish keyboard layout. So, without custom remaps, it completely breaks the usability of the built-in terminal.

I'm using a custom mapping myself, so I did not think of it, but I recently had to do some testing with a clean nvim configuration, and had big problems. I almost ran into the meme of not being able to exit vim. But fortunately, you can type exit to exit the terminal. Still, it's not possible to do anything else, while keeping the terminal open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants