React-leaflet get ctrlKey press event

Multi tool use
Multi tool use


React-leaflet get ctrlKey press event



I try to handle ctrlKey + click vs click event.



eventHandler


seatClickHandler = (event, seat) => {
console.log(event);
console.log(seat);
};



component on which is clicked.


<Circle onClick={ (event) => this.seatClickHandler(event, seat) }
key={seat['id']}
center={[x, y]}
radius={7} />



I tried to check for event.ctrlKey but it is undefined.


event.ctrlKey



How can I find out if ctrl or shift key is holding on click happens?



Problem is that I can not use reactJs events from react-leaflet event.
In example if I run event.stopPropagation(); I get fatal error.


event.stopPropagation();





I had checked solution from this answer but still no solution. I can not use react events from a leaflet event.
– Stevan Tosic
Jul 3 at 9:11




1 Answer
1



Leaflet has its own events. If you want to access the original click event you need to do it through the originalEvent property on the leaflet event:


originalEvent


if (event.originalEvent.ctrlKey) {
// handle ctrl + click ...
}



Every property you expect a DOMEvent to have will be on this object instead of the leaflet event object. This does also include stopPropagation().


DOMEvent


stopPropagation()






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

y4,BaUhnsDisE9u2mn5H4HcSV8NkKuqLkP55bVd,mYJdFU9mxU7hnDSnqAA,2ys,m,qwCTx22BD IfkY OMw2mFnswm 7mggd,Ib4GFry
OqUTLaYpIfxCy HOFcERyRK9kfm9pEtGBYbQekpPVl,YSP32O7

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications