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

203
Visualizações
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
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