3

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.) ?

3
  • 1
    What is it exactly you're trying to achieve by detecting a keyboard's layout? Commented Sep 23, 2021 at 7:08
  • 1
    You could ask them to press the first 5 keys of the first 2 rows in order and check for matches. Commented Sep 29, 2021 at 21:17
  • Related, but the answers there don't support Firefox: stackoverflow.com/questions/8892238/… Commented Sep 7, 2022 at 7:43

1 Answer 1

4
+100

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.