React-leaflet get ctrlKey press event

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();
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.
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