Skip to content

CMD+Shift is not reported correctly on macOS #3078

@fredizzimo

Description

@fredizzimo

The corresponding bug in Neovide is neovide/neovide#1237

I have been wanting report this bug for quite some time now, since it has caused a pretty bad regression in Neovide, and has a big impact for some users. But unfortunately, I don't own a Mac, so it has been difficult to gather the information I need to report it.

The issue is that CMD + character reports the same text as CMD + Shift + character, the text always contains the base character. This does not play well with Vim, which assumes that you map the resulting characters, not a key + modifiers. We do know from the modifiers that shift is pressed, but that information can't really be used without knowing the keymap, it's possible to turn standard alpha keys to uppercase, but in combination with the number keys for example, we don't have any idea what character to send to Neovim.

Here's a trace captured through the Neovide logging, where CMD+shift+d was pressed.

TRACE [neovide::window::keyboard_manager] KeyEvent {
    physical_key: SuperLeft,
    logical_key: Super,
    text: None,
    location: Left,
    state: Pressed,
    repeat: false,
    platform_specific: KeyEventExtra {
        text_with_all_modifiers: None,
        key_without_modifiers: Super,
    },
}
TRACE [neovide::redraw_scheduler] Next frame queued
TRACE [neovide::window::keyboard_manager] KeyEvent {
    physical_key: ShiftLeft,
    logical_key: Shift,
    text: None,
    location: Left,
    state: Pressed,
    repeat: false,
    platform_specific: KeyEventExtra {
        text_with_all_modifiers: None,
        key_without_modifiers: Shift,
    },
}
TRACE [neovide::window::keyboard_manager] Modifiers { state: ModifiersState(SHIFT | SUPER), pressed_mods: ModifiersKeys(LSHIFT | LSUPER) }
TRACE [neovide::window::keyboard_manager] KeyEvent {
    physical_key: KeyD,
    logical_key: Character(
        "d",
    ),
    text: Some(
        "d",
    ),
    location: Standard,
    state: Pressed,
    repeat: false,
    platform_specific: KeyEventExtra {
        text_with_all_modifiers: Some(
            "d",
        ),
        key_without_modifiers: Character(
            "d",
        ),
    },
}

As, you can see, there's absolutely no way of translating this to <D-D>, which Neovim wants, instead of <D-d>, other than manually detect that shift is pressed and try to convert it to uppercase, and hope that's the correct character. But as mentioned, it only deals with the alphas, and without other modifier combinations.

All the other platforms report this correctly, well, they don't have CMD, but alt+shift+character, for example works correctly (except for some combinations #3012). I have no idea if alt and other combinations work correctly on macOS or not, since I have not been able to gather that information and that's why I have been waiting to create this issue before now.

Note that we are using 0.29.0-beta0, and since I can't test this myself, I haven't done any testing on beta1, but I don't see anything in the changelogs that would indicate it's fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    B - bugDang, that shouldn't have happenedDS - macos

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions