InputEvent.isComposing(MDN)に対応していない環境でも入力の変換中かどうかをチェックするためのものです。
判定可能なイベントは
- keydown
- keyup
- beforeinput
- input
です。 それぞれ、対応している環境の場合はネイティブの値を返します。
実際の例は example ディレクトリーにあります。
const compositionObserver = new CompositionObserver.default();
compositionObserver.start();
function inputHandler(event) {
if (compositionObserver.isComposing(event)) {
return;
}
// do something
}
someInputElement.addEventListener("input", inputHandler, false);isComposing(event): 変換中かどうかstart(): 監視を開始しますstop(): 監視を停止します
MIT