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

292
Views
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
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!