Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

100
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda