Skip to content

ISO Keyboards: Backslash and IntlBackslash "swapped" #24153

Closed

Description

  • VSCode Version: 1.11.1
  • OS Version: macOS 10.12.4
  • British Keyboard Layout
  • All extensions disabled

Whenever I try to use shortcuts which use the § and ` keys, their values appear to be reversed. The keys work correctly on every other app and everywhere else within VS Code; it's specifically when they're used as shortcuts. The problem extends to when I try to rebind them as well:

image

image

(Ignore the 'shift+command', they came from taking the screenshot!)

To be clear, the 'key' value is the correct one and the 'UI' value is the incorrect one the shortcut recognises.

Activity

  1. added
    macos
    keyboard-layout
    on Apr 7, 2017
  2. alexdima commented on Apr 7, 2017

    @alexdima
    Member

    Tom Burnett (@TomBurnettUK) This might be an issue in our C++ node module that reads information about the current keyboard layout. Could you please:

    • open an editor
    • press F1 > Developer: Inspect Keyboard mappings
    • save the contents to a file
    • attach the file here

    I could then examine what the C++ node module determines for the [Backquote] scan code.

  3. TomBurnettUK commented on Apr 7, 2017

    @TomBurnettUK
    Author

    Sure! Here's the file.

    KeyMappings.txt

  4. changed the title [-]Incorrect key values for shortcuts[/-] [+]Backslash and IntlBackslash "swapped" under British Keyboard Layout[/+] on Apr 10, 2017
  5. changed the title [-]Backslash and IntlBackslash "swapped" under British Keyboard Layout[/-] [+]British Keyboard Layout: Backslash and IntlBackslash "swapped"[/+] on Apr 10, 2017
  6. added
    bug
    on Apr 26, 2017
  7. changed the title [-]British Keyboard Layout: Backslash and IntlBackslash "swapped"[/-] [+]ISO Keyboards: Backslash and IntlBackslash "swapped"[/+] on Apr 28, 2017
  8. alexdima commented on Apr 28, 2017

    @alexdima
    Member

    Thanks to investigation help from Johannes Rieken (@jrieken) and his ISO keyboard, we were able to reproduce. The root problem is simple, our native C++ node module reads the scan codes -> chars mapping correctly, but Chromium decides to "swap" the KeyboardEvent.code [Backquote] and [IntlBackslash] on OSX on ISO keyboards in order to try to stay w3c compliant.

    Here is the offending code:
    https://cs.chromium.org/chromium/src/ui/events/keycodes/keyboard_code_conversion_mac.mm?type=cs&q=LMGetKbdType+package:%5Echromium$&l=809

    int ISOKeyboardKeyCodeMap(int nativeKeyCode) {
      // OS X will swap 'Backquote' and 'IntlBackslash' if it's an ISO keyboard.
      // https://crbug.com/600607
      switch (nativeKeyCode) {
        case kVK_ISO_Section:
          return kVK_ANSI_Grave;
        case kVK_ANSI_Grave:
          return kVK_ISO_Section;
        default:
          return nativeKeyCode;
      }
    }
    
    DomCode DomCodeFromNSEvent(NSEvent* event) {
      if (KBGetLayoutType(LMGetKbdType()) == kKeyboardISO) {
        return ui::KeycodeConverter::NativeKeycodeToDomCode(
            ISOKeyboardKeyCodeMap([event keyCode]));
      }
    
      return ui::KeycodeConverter::NativeKeycodeToDomCode([event keyCode]);
    }

    We need to figure out a way on our side to "unswap" them...

  9. added a commit that references this issue on Sep 21, 2017
  10. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugkeybindingskeyboard-layoutmacos

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions