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

202
Views
Triggering arrow keypressing and movement inside textarea (javascript)

How can I trigger arrow press inside textarea with keyboardevent constructor in order to navigate through text? Can anyone help or point out?

        case "left_arrow":
      keyElement.classList.add("keyboard__key");
      keyElement.setAttribute("id", "left_arrow_keyboard");
      keyElement.innerHTML = createIconHTML("arrow_left");

      //keyelement is a button
      keyElement.addEventListener("click", () => {
        const event = new KeyboardEvent("keydown", {
          which: 37,
          key: "ArrowLeft",
          code: "ArrowLeft",
          location: 0,
          altKey: false,
          ctrlKey: false,
          metaKey: false,
          shiftKey: false,
          repeat: false,
        });
        this.properties.value += document.dispatchEvent(event);            
        event.preventDefault();
        this.triggerEvent("whenInput");
      });

      break;

and I'm getting "true" inside textarea, instead of the actual caret/cursor movement P.S. - I'm on JS vanilla, but open to jQuery

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!