Skip to content

Use keyboard API to detect the layout #321

Closed as not planned
Closed as not planned
@mattgodbolt

Description

@mattgodbolt

See https://developer.mozilla.org/en-US/docs/Web/API/Navigator/keyboard

can improve

jsbeeb/utils.js

Lines 379 to 391 in c0735c2

function detectKeyboardLayout() {
if (exports.runningInNode) {
return "UK";
}
if (localStorage.keyboardLayout) {
return localStorage.keyboardLayout === "US" ? "US" : "UK";
}
if (navigator.language) {
if (navigator.language.toLowerCase() === "en-gb") return "UK";
if (navigator.language.toLowerCase() === "en-us") return "US";
}
return "UK"; // Default guess of UK
}
with this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions