Does js know which input method is currently used and whether the current input method uses English input or Chinese input?

such as the question, for example, my computer now has Sogou Input and intelligent ABC input methods. I typed this paragraph using Sogou Input. Can js get the Chinese input or English input of Sogou I am using now?

clipboard.png

js


clipboard.png

English input is: sdfdfdsfdsfds

what I want is to judge the status of this input method, not whether the input value is in Chinese or not.

Mar.21,2021

there will be events such as compositionstart in the input process of the Chinese input method, but not in the general English input method. I don't think you can get it by entering a legal name.


expressions are neither Chinese nor English.

generally determines whether it is Chinese

by judging the encoding of the input characters.
/ ^ [\ u3220 -\ uFA29] + $/ / / is Chinese

after you can't do anything before user input, you can monitor input events if it is judged to be Japanese
the browser is not good enough to expose that js api sends messages to other processes, and the input method does not expose the messages that api monitors other processes.

var reg = /[^]/;
on('input', function(val) {
   var _temp = val.match(reg);
   if (reg) {
        input.value= reg[0];
   } else {
        input.value = '';
   }
});
Menu