I need to change this so it isn't using the depreciated keycode?
if(event.keyCode >= 48 && event.keyCode <= 90) {
//the key pressed was alphanumeric
}
I know how to do the a-z and the 0-9 but what about the special chars between (between 48 & 90 that are not a-z and 0-9)?
I'm sorry if this is a duplicate. I did look first but I didn't find anything that includes the "keys" between, only the a-z and 0-9. If it is a duplicate, could you share a link?
You could use regex if it doesn't need to be event.code.
if(event.key.match(/[^a-zA-Z0-9]/)) {
//the key pressed was NOT alphanumeric
}
event.key:
The value of the key pressed.
Accounts for modifiers keys that return CAPS and alternate chars.
event.code:
The physical key on the keyboard.
Doesn't care if you are holding a modifier like Shift.