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

218
Views
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
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!