Inconsistent support for local keyboard layouts

Steps to reproduce

  • Set the keyboard mapping in your OS to anything but en-us, say de-sg (Swiss German instead of American English)
  • In any Obsidian vault, select options/hotkeys
  • pick any command, for instance “Add embed”
  • holding the shift key, press the key just to the right of the digit ‘0’ (which is labelled as the tick mark on the Swiss German keyboard)

Expected result

  • The hotkey should be shown as shift - ’ (tick )

Actual result

  • The hotkey panel now has assigned shift + [ (left bracket)
  • pressing shift + [ (left bracket) will not invoke the intended command (Add embed)

Environment

  • Operating system: Ubuntu Desktop 20.04.3 LTS
  • Obsidian version: v0.12.19

Additional information

  • When entering text, the local keyboard is completely and correctly mapped. All special keys appear to produce the glyph that’s engraved on the corresponding keys (and that’s listed in the keyboard mapping supplied by the OS)

  • When used as ‘hotkeys’, the keys A…Z and 0…9 (above the alphabet keys) produce the correct glyphs, even if they are not in the same place as on the American English keyboard. The German keyboards transpose the Z and Y keys with respect to the English ones. I have not tested any keyboards in any other languages (AZERTY-Keyboard for French) or even other scripts (Greek, for instance).

  • for all other keys, the hotkey listing shows the glyphs as they are engraved on the same key on the American English keyboard.

  • The following figure shows the affected keys on the left hand side of the keyboard, i.e. the keys immediately to the left of the ‘1’ and the ‘z’ keys.
    American English:
    file:///home/philipp/Primeli/Technisches/Software/Obsidian/en-left.png
    grafik
    Swiss German:
    file:///home/philipp/Primeli/Technisches/Software/Obsidian/sg-left.png
    grafik

  • Those figures show the affected keys on the right hand side of the keyboard.
    All white keys to the right of ‘0’, ‘p’, ‘l’, and ‘m’, respectively, are affected
    American English:
    file:///home/philipp/Primeli/Technisches/Software/Obsidian/en-right.png
    grafik
    Swiss German:
    file:///home/philipp/Primeli/Technisches/Software/Obsidian/sg-right.png
    grafik

  • Impact: the inconsistent mapping will utterly confuse beginners and trained users alike. Initially, very few hotkeys are affected out of the box, notably Shift + and Shift /. As a consequence, the forum will gather a number of bug reports all caused by hotkeys not performing as expected or by key presses resulting in unexpected results, all hard to track down because they all affect keyboard layouts the developers of Obsidian may not be familiar with.

  • The hotkey listing should show the keys as they are known to the local user, i.e. it should apply the correct keyboard mappings.

After entering the report I noticed that the wrong mapping does not return the glyphs as expected by the en-us mapping. I don’t know what mapping is applied, if any.

This is quite a complex subject and unfortunately the API to handle keyboards and layouts suck. We struggled a lot with this and I don’t think we’ll be able to improve on it until the underlying stack improves.

Even if the hotkey does not match what your would get from your current keyboard layout, it will work fine following the actual buttons you pressed (as long as you don’t change layout).
The hotkey that appears is the one that you would have to perform if you were using a US keyboard.

Feel free to open a feature request to track this.