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

153
Views
Unable to page refresh when I add window.addEventListener inside the component class

I have issues refreshing the page when I have window.addEventListener snippet in the component class.

componentDidMount() {
    window.addEventListener("keydown" , function(event) {
        event.preventDefault();
        if (event.keyCode === 13) {
            document.getElementById("searchLink").click();
        }
    });
}

Note: ctrl+f5 doesn't work, all keyboard actions fail to work when I have this snippet enabled. even the chrome console is not opening with the keyboard shortcut. Refreshing the page with mouse pointer also doesn't work in the browser.

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

0

componentDidMount() {
    window.addEventListener("keydown" , function(event) {
        if (event.key === "Enter") {
            event.preventDefault();
            document.getElementById("searchLink").click();
        }
    });
}

preventDefault is canceling all keyboard key press

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!