Is there a way to detect a client's keyboard layout in Firefox?
I know the answer is yes with Chrome (see https://developer.mozilla.org/en-US/docs/Web/API/Navigator/keyboard):
navigator.keyboard.getLayoutMap().then(function(k) { console.log(k.get('KeyQ')); }); // A or Q gives a hint about the layout
Is there another way for other browsers (Firefox, Safari, etc.) ?
There is currently no way to detect the keyboard layout through Javascript in Firefox.
The feature is currently experimental in Chromium based browsers. For Firefox you can track the progress here: https://bugzilla.mozilla.org/show_bug.cgi?id=1469017
As of today the last update on the bug was 2020-06-05. One of the last substantial posts in that thread said:
[...] exposing this information is really strong fingerpintting source. Finally, Apple has already refused. So, I think that we do not need to this API.
You can follow Mozilla's official position on this API here: https://mozilla.github.io/standards-positions/#keyboard-map
Currently it's classified as "harmful", and states:
We're concerned that this exposes keyboard layouts, which seem likely to be a significant source of fingerprinting data, in a way that does not require any user interaction.
I do not expect this capability will be supported on Firefox in the foreseeable future.