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

210
Vistas
React trigger event through mouse click on span

I am in react application and have an span in my code and there I placed the smilie icon. On click of span I want to trigger the window + > event.

On chrome in windows platform this shortcut i.e window + > windows + period key will open the emoji's. I want to to trigger that through span click

My code:

<span style={{position: "absolute"}} onClick={(e) => this.getTrigger(e)}>&#128522;</span>

Function written just above the render() in react.

getTrigger = (e) => {
    e.stopPropagation();
    // let getEvent = document.addEventListener('mousedown');
    alert('event Clicked', getEvent)
    // I need to trigger the window + > event here
  }

What I have found is basically detection of key.

if(e.keyCode === '13') {
 //do something
}

But I need to fire/trigger the event not get detection.

I also get the way to be done but not able to resolve this:

// Event listener
document.addEventListener("eventName", function(e) {
  console.log(e.detail);
});

// Event create
let event = new CustomEvent("eventName", { "detail": "Event creation" });

// Dispatch/Trigger/Fire the event
document.dispatchEvent(event);

Can anyone guide me how to solve this.

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