javascriptkeyboard-layout

detect keyboard layout with javascript


Is there any way to detect the current keyboard layout using JavaScript? I found this, but it only detects if the visitor is on the english layout. I need to know the exact layout as a string, e.g.de-ch, fr or en.


Solution

  • Keyboard layouts do not have standardized identifiers. They have names assigned to them by the layout creator. They may have a language association as one defined property.

    The Keyboard layouts should not be confused with language or locale identifiers. In particular there is no single “English layout” but dozens of layouts that may be used for English.

    I don’t think systems normally make their current layout settings readable via JavaScript.

    So whatever problem you are trying solve by detecting the keyboard layout, a different approach is needed.