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)}>😊</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.