all articles

firefox triggers no keyup event when IME is on

2015-07-05 @sunderls

firefox keyup IME js

desc

firefox triggers no keyup event when IME is on(like inputing Japanese.

take Chrome as an example

englisth letters

actionchrome eventfirefox(37.0.1) event
focus & typeinput , keyup input, keyup
copy & paste by keyboardinput , keyup(x2)input, keyup(x2, sometimes x1)
copy & paste by mouseinputinput
lose focuschange(if text changes)change(if text changes)

Japanese Chinese..

actionchrome eventfirefox(37.0.1) event
focus & typekeyup, inputinput
change suggest by keyboard arrow keyskeyup, inputinput
change suggest by mouseinputinput
prechoose & close suggest by keyboardkeyup(no event)
close suggest by dbclickinput x2input x2
confirm suggest by keyboard(remove the underline)input,keyupinput x2
confirm suggest by typing next letter(remove the underline)input x2,keyupinput x2

while val().length is right counted, right with the selected option.

conclusion

use event:input instead.

or since other browsers' behaviors are not confirmed yet, you may use following workaround

workaround

user interval to check the input continuously until it lose focus

var timer = null;

$input.on("focus", function(e){
    var that = this;
    clearInterval(timer);
    timer = setInterval(function(){
       // check input here
    }, 200);
})
$input.on("blur", function(){
    clearInterval(timer);
    timer = null;
});