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

Closed
mattgodbolt opened this issue Jun 6, 2021 · 1 comment
Closed

Use keyboard API to detect the layout #321

mattgodbolt opened this issue Jun 6, 2021 · 1 comment

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

@mattgodbolt
Copy link
Owner Author

It really doesn't seem that the keyboard API is well supported, and even if it was it doesn't seem obvious that the KeyboardLayoutMap would be the solution to this. Going to close.

@mattgodbolt mattgodbolt closed this as not planned Won't fix, can't repro, duplicate, stale Dec 27, 2024
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