H5 how to solve the problem of typing without pinyin in iOS native input method caused by composition event?

for example, the following code mainly restricts the input.

var cpLock;
$("-sharpinput").on("compositionstart", function(e) {
    cpLock = true;
});
$("-sharpinput").on("compositionend", function(e) {
    cpLock = false;
});
$("-sharpinput").on("input", function(e) {
    if (!cpLock) {
        if (e.target.value.length - 17 >=0) {
            var txt = $(e.target).val().substring(0, 16);
            $(e.target).val(txt);
            // 16
        }
    }
});

after testing, there is no problem with the third-party input method and the original Ninomiya keyboard in iOS, but switching to the full keyboard will cause the candidate Pinyin to disappear. How to solve it?

reference:

Jun.22,2022
Menu