Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda