From 777905e7f1a73a6b021d4a142491cd5aa17668ae Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Sat, 25 Apr 2020 18:08:23 +0200 Subject: [PATCH] Press escape in the editor to stop drawing --- htdocs/streeteditor.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/streeteditor.js b/htdocs/streeteditor.js index 4ade184..230324c 100644 --- a/htdocs/streeteditor.js +++ b/htdocs/streeteditor.js @@ -103,9 +103,17 @@ if (editor_mode) { window.addEventListener("hashchange", editor_onHashChange, false); window.addEventListener("mouseup", onDragEnd, false); // Workaround as polyline.on(dragend, ) doesn't seem to work + function onMapKeydown(e) { + if (e.originalEvent.key == "Escape") { + if (polyline) + polyline.editor.cancelDrawing(); + } + } + // Configure map for better editing mymap.setMaxZoom(14); mymap.off('click', onMapClick); + mymap.on('keydown', onMapKeydown); function get_location_string() { var latlngs;