Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use keyboard API to detect the layout #321

Open
mattgodbolt opened this issue Jun 6, 2021 · 0 comments
Open

Use keyboard API to detect the layout #321

mattgodbolt opened this issue Jun 6, 2021 · 0 comments

Comments

@mattgodbolt
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant