0

I was able to find code for getting current keyboard language on-key-press, but I want to get this data on-click. Meaning, when the user click on screen -> alert('EN/FR/SP').

Maybe it's an OS issue and not related to browser, but is there a way to create a code like this (Javascript or other)?

Community
  • 1
  • 1
Eshchar
  • 53
  • 6

2 Answers2

0

Does the following not work?

$('body').on('click', function(){
    alert(navigator.language);
});
An0nC0d3r
  • 1,275
  • 13
  • 33
  • Thanks but these codes give me the browser's lang, while I want the OS keyboard lang (the language you're currently typing in the browser). – Eshchar Oct 21 '15 at 16:28
  • Oh OK, can I ask why on earth you would need that information? – An0nC0d3r Oct 21 '15 at 16:31
  • Found this, trying to understand if it can help (Mac): https://github.com/Lutzifer/keyboardSwitcher – Eshchar Oct 21 '15 at 16:57
  • Hey Adam, I want to get an app for school's project able to detect your lang at any time, little hard to explain the whole process, but it has to know keyboard language. – Eshchar Oct 21 '15 at 17:03
  • Please see Jukka K. Korpela answer http://stackoverflow.com/questions/8892238/detect-keyboard-layout-with-javascript. Think that should answer your question once and for all – An0nC0d3r Oct 21 '15 at 17:21
  • I think it does, I'll have to use a different approach - maybe Java or C++. Thanks again! – Eshchar Oct 21 '15 at 17:38
-1

I think the best you can do is get the browser's language, but of course that's not necessarily the same thing:

var lang = navigator.language || navigator.userLanguage;
document.write(lang);
Schlaus
  • 18,144
  • 10
  • 36
  • 64