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

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