This page demonstrates browser functionality when a listener for the 'keydown' event immediately cancels the event it receives.
How to use:
Both addEventListener
and onkeydown
should prevent you from being able to add or remove characters by typing. You should still be able to cut and paste text using a context menu.
Event listener:
input.addEventListener("keydown", (e) => { e.preventDefault(); });
input.onkeydown = () => false;