Javascript: event.preventDefault() does not work for Japanese IME

Viewed 718

I want to create a text input which does not allowed to input any character (same as disabled input, but the mouse cursor still shown)

function loadPage() {
  const el = document.getElementById('input-id');
  el.addEventListener('keydown', (event) => {
        event.preventDefault();
  });
}
loadPage();
<input maxlength="0" id="input-id">

The above code works fine for normal alphabet characters. However, when I use IME to type Japanese fullwidth character, it does not work (still can input character)

Do you know where is the problem, and is there anyway to workaround?

0 Answers
Related