v145 · Web APIs · InputType Monitor

InputType Monitor

Type in the editor, select some text, then press Backspace, Ctrl+Backspace, or Ctrl+Delete. The log shows the exact inputType from each beforeinput event. In Chrome 145, word/line deletion with a selection reports the correct granularity type.

To see the Chrome 145 fix: Select multiple words (click and drag), then press Ctrl+Backspace. Before Chrome 145 this reported deleteContentBackward; after Chrome 145 it reports deleteWordBackward, matching the user's actual intent.

editor

Click to focus, type, select text, then use deletion shortcuts:

Backspace char backward · Delete char forward · Ctrl+Backspace word backward · Ctrl+Delete word forward
The quick brown fox jumps over the lazy dog. Try selecting some of these words and pressing Ctrl+Backspace.

beforeinput event log

Focus the editor above and type or delete to see events…

code

element.addEventListener('beforeinput', event => {
  const type = event.inputType;
  const isWordDeletion = type.includes('Word');
  const isLineDeletion = type.includes('Line');
  const ranges = event.getTargetRanges();

  if (isWordDeletion || isLineDeletion) {
    // Chrome 145: correctly set for selections too
    event.preventDefault(); // intercept for custom undo handling
    handleGranularDeletion(type, ranges);
  }
});

see also