SyntaxFix
Write A Post
Hire A Developer
Questions
Have you tried using 'onkeydown'? This is the event you are looking for.
It operates before the input is inserted and allows you to cancel char input.