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

250
Visualizações
How to select input tag on keypress

Hey I have a list of input tags , I am navigating through all input tags using arrowUp and arrowDown keys I want to select input tag on pressing enter key and start typing.

<input type="text" /> selected and start typing on keypress enter
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Try this :

var el = document.getElementById("myInputID");
el.addEventListener("keydown", function(event) {
    if (event.key === "Enter") {
        // Enter key was hit
    }
});
about 4 years ago · Juan Pablo Isaza Relatório

0

let's imagine you have <div class="container"> with list of inputs:

<div id="container">
    <input type="text" value="1">
    <input type="text" value="2">
    <input type="text" value="3">
</div>

    document.getElementById('container').querySelectorAll('input').forEach((node) => {
      node.addEventListener('keydown', (event) => {
        if (event.key === 'Enter') {
          // your logic here
        }
      })
    })
about 4 years ago · Juan Pablo Isaza Relatório

0

    <input type="text" id="text1"><script>
    window.addEventListener("keydown", (event)=>{if (event.key == 'Enter') {document.getElementById("text1").focus()} })</script>

but this works only if you have one element

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