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

294
Visualizações
How to make keyPress activate a handleClick in Typescript/React

Making a simple registraction form in React/TS, and I'm trying to make the Enter key perform the role of clicking Next. It should do everything that the next button does, which is defined in handleClick.

    function handleKeyPress(e: React.KeyboardEvent<HTMLDivElement>) {
        if (e.code === "Enter") {
            handleClick( // some argument here // );
        }
    }

    function handleClick(e: React.MouseEvent<HTMLButtonElement>) {
        if (!first || !last) {
            return setError(true);
        }
        step(e, `${e.currentTarget.name}`);
        updateName(e, first, last);
    }

I cannot work out which argument to pass to handleClick, in order to satisfy Typescript. It requires 1 argument.

I have tried passing e: React.MouseEvent, and variations of arbitrary arguments. What am I missing here?

about 4 years ago · Juan Pablo Isaza
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