microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.96k stars 28.24k forks source link

IntlBackslash swapped with Backquote on ISO keyboards on Chrome & Firefox #163432

Open samdenty opened 1 year ago

samdenty commented 1 year ago

The keybindings are broken on MacOS for "`" & "§". You can see this by going to https://vscode.dev / https://github.dev on MacOS, opening the keyboard shortcut picker, clicking on a shortcut to edit & pressing both them keys.

Alternatively you can reproduce by pressing "CTRL+`", to open the terminal which doesn't work

ScanCode 106 (106 in enum) is detected as IntlBackslash (§) when it should be "`" https://github.com/microsoft/vscode/blob/5e2f5e57cb2d3a222d43de51541b0eda207914e8/src/vs/base/common/keyCodes.ts#L334.

This is with the British layout:

CleanShot 2022-10-12 at 15 28 58@2x
fny commented 1 year ago

Hmm... this works for me (ctrl + `), but I have a different issue. The keybindings from my window tiling app stopped working entirely. Perhaps related?

samdenty commented 1 year ago

I think that's because vscode intercepts all keyboard shortcuts, COMMAND+SHIFT+B to toggle bookmarks bar also doesn't work

fny commented 1 year ago

Just to add, I noticed this change after upgrading to the latest release.

roblourens commented 1 year ago

In case this helps https://github.com/microsoft/vscode/wiki/Keybinding-Issues#summary

samdenty commented 1 year ago

@roblourens is there a reason why it's broken in VSCode Web, but not on desktop? Setting keyboard.dispatch to keyCode fixes web, but it works with code on desktop

alexdima commented 1 year ago

is there a reason why it's broken in VSCode Web

Yes, on the desktop we have a native node module which we use to detect the key mappings. On the web, we need to rely on web APIs, which are incomplete.

fny commented 1 year ago

This is happening to me on desktop FWIW.

On Sun, Oct 23, 2022, 12:47 PM Alexandru Dima @.***> wrote:

is there a reason why it's broken in VSCode Web

Yes, on the desktop we have a native node module which we use to detect the key mappings. On the web, we need to rely on web APIs, which are incomplete.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode/issues/163432#issuecomment-1288152431, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACUPVGTJXZSPVBEQWSLY6TWEVT2NANCNFSM6AAAAAARDK5H5U . You are receiving this because you commented.Message ID: @.***>

MasterInQuestion commented 1 year ago

= Keybindings broken in VSCode web =

    Similar also happening on Android:     |*| 【F1】 ("Command Palette") outright not responding.     |*| 【Ctrl】 + 【A】 ("Select All") has no effect [1] while 【Ctrl】 + 【C】/【V】 ("Copy" / "Paste") would work.     |*| 【Tab】 could not be trapped. (causes keyboard navigation)     |*| And many more. [1] Not happening in Chromium.

    Setting `"keyboard.dispatch": "keyCode"` fixes the problem.

    ----

    The portable way that should work from ancient IE to any modern mainstream browser is: (JavaScript) [[

    if (
    e.ctrlKey === true &&
    (
    e.keyCode === 65 ||
    e.which === 65 ) ) {

//  E.g. handling 【Ctrl】 + 【A】.
    };

]]

alexdima commented 1 year ago

@fny @MasterInQuestion Keybindings are OS, browser and keyboard layout dependent, which means you are running into problems which are distinct from the problem reported by the OP. Please open separate issues if you still have keybindings problems.

alexdima commented 1 year ago

@samdenty What browser are you using?

samdenty commented 1 year ago

Chrome on MacOS with British layout

alexdima commented 1 year ago

@samdenty Thanks for your prompt reply. I believe this is caused by this piece of code in Chromium: https://source.chromium.org/chromium/chromium/src/+/main:ui/events/keycodes/keyboard_code_conversion_mac.mm;l=809-820?q=LMGetKbdType%20package:%5Echromium$&ss=chromium where they swap Backslash and IntlBackslash on macOS on ISO keyboards. For the VS Code build, we maintain a patch where we delete that code. We hit this before with https://github.com/microsoft/vscode/issues/24153

Does this reproduce in Firefox?

Edit: Found a newer bug on Chromium's side: https://bugs.chromium.org/p/chromium/issues/detail?id=1296783 fyi @deepak1556

samdenty commented 1 year ago

It works for me in safari but it's broken for me in Firefox & Chrome with keyboard.dispatch: code. Setting it to keycode fixes it, but makes both keys input the '`' character instead of IntlBackslash

alexdima commented 1 year ago

Issue for Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1755096

deepak1556 commented 1 year ago

Found a newer bug on Chromium's side: https://bugs.chromium.org/p/chromium/issues/detail?id=1296783

Awesome, this should help us remove the patch.

samdenty commented 1 year ago

Yep, I can confirm it's broken in both Firefox/Chrome with doing:

window.onkeydown = (e) => console.log("code:", e.code, "key:", e.key);
MasterInQuestion commented 1 year ago

    [ Quote alexdima @ CE 2022-12-06 21:27:18 UTC: https://github.com/microsoft/vscode/issues/163432#issuecomment-1340028915     Keybindings are OS, browser and keyboard layout dependent, which means you are running into problems which are distinct from the problem reported by the OP. ] <^>    Fundamentally caused by identical cause. (key binding in default configuration in general broken across browsers)

    It's serious. (though proclaimed non-standard deprecated)     Testable with example: https://github.com/MasterInQuestion/Markup/blob/main/picdif.htm

mardybardy commented 10 months ago

Still broken on Chrome almost a year later.