I want to intercept the key event going to an HTML text field in JavaScript, ignore it, then perform my own custom update on the field. Currently I’m using an onKeyPress listener to replace it after the fact, but there’s a flickering as the entered text is replaced by the modified text. How can I intercept the key events to keep them from getting processed by the text field? I’d like to avoid a transparent div if possible. Thanks!
Share
Catch the key down event and call `preventDefault()’ . It will cancel the default action of updating the text input.