geoman-io / leaflet-geoman

🍂🗺️ The most powerful leaflet plugin for drawing and editing geometry layers
https://geoman.io
MIT License
2.21k stars 433 forks source link

[Q] - Catch map events with a pressed key #781

Closed AndrejGajdos closed 3 years ago

AndrejGajdos commented 3 years ago

I would need to able to catch map event pm:create when user draw a shape with shift key pressed.

Leaflet provides originalEvent object in MouseEvent object to be able to catch mouse events with a key pressed.

I think it would be possible to implement this by creating click event on map. There I can find out if shift was pressed on the first and the last click when a new shape was created by geoman. In pm:create event I can get the global variable and check if shift was pressed.

I am wondering if there is a better way to find out if shift was pressed directly in pm:create without implementing an additional click event on map.

Falke-Design commented 3 years ago

No I don't think that there is a better way

AndrejGajdos commented 3 years ago

Ok, thanks. Maybe you can consider this as a feature request. I just tried that approach described above and it works well.