Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
How do I convert this to use event.code instead of event.keycode?

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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.

Ref: https://keycode.info/

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!