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

143
Views
How do I get pressing the enter key to stop being treated like a mouse click in javascript?

I have a program where I have several clickable buttons as well as a reason to click enter. Issue is, if I click a handful of the buttons with the mouse and then click the enter key on my keyboard, it does what enter should do and it also acts as though I had clicked the last button that I clicked one more time. I want the clicking to only be done with the mouse and have the enter key not be able to click buttons. How do I do this? code Here is how I am currently making the buttons clickable and getting the input of the keyboard.

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

0

By clicking on the tile button, it gets focus. Hence, subsequent enter triggers the button.

You could "un-focus" the button:

// tile is a reference to the button, as per your question
tile.addEventListener('click', (evt) => {
  // un-focus
  tile.blur();
  // do some stuff
});
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!