Dangerous Input Text

Hello,

I am making an interactive that takes text input and displays things based on that input. What I need help with is handling special characters. For instance if a user tries to input a semi-colon ‘;’ I want to catch it RIGHT WHEN THEY DO IT and not allow it so that a user can’t inject malicious code.


if (evt.keyCode == )//Semicolon
 {
  remove the character from the input textfield before they can hit the enter key.
 }