Skip to content

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

@fredizzimo

Description

@fredizzimo

On Windows, when pressing a key in combination with altgr for example ctrl+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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    DS - win32Affects the Win32/Windows backend

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions