If you want to check the range of letters, you can use more and less:
if (event.keyCode >= 48 && event.keyCode <= 57) alert("input was 0-9"); if (event.keyCode >= 65 && event.keyCode <= 90) alert("input was az");
For a more dynamic check, use a regex:
var inp = String.fromCharCode(event.keyCode); if (/[a-zA-Z0-9-_ ]/.test(inp)) alert("input was a letter, number, hyphen, underscore or space");
See the MDC documentation for the keyCode property, which explains the difference between this and the which property and what events they apply to.
Andy E Feb 13 2018-10-10T00 : 00Z
source share