diff --git a/js/plugin/RoutingPathQuality.js b/js/plugin/RoutingPathQuality.js index 1ed5e11..76dd6bc 100644 --- a/js/plugin/RoutingPathQuality.js +++ b/js/plugin/RoutingPathQuality.js @@ -1,6 +1,7 @@ BR.RoutingPathQuality = L.Control.extend({ options: { shortcut: { + toggle: 67, // char code for 'c' muteKeyCode: 77 // char code for 'm' } }, @@ -140,7 +141,7 @@ BR.RoutingPathQuality = L.Control.extend({ }); } - if (this.options.shortcut.muteKeyCode) { + if (this.options.shortcut.muteKeyCode || this.options.shortcut.toggle) { L.DomEvent.addListener(document, 'keydown', this._keydownListener, this); L.DomEvent.addListener(document, 'keyup', this._keyupListener, this); } @@ -192,10 +193,16 @@ BR.RoutingPathQuality = L.Control.extend({ }, _keydownListener: function(e) { - if (BR.Util.keyboardShortcutsAllowed(e) && this._active && e.keyCode === this.options.shortcut.muteKeyCode) { + if (!BR.Util.keyboardShortcutsAllowed(e)) { + return; + } + if (this._active && e.keyCode === this.options.shortcut.muteKeyCode) { this._muted = true; this._deactivate(this.routingPathButton); } + if (!this._muted && e.keyCode === this.options.shortcut.toggle) { + this.routingPathButton.button.click(); + } }, _keyupListener: function(e) { diff --git a/locales/en.json b/locales/en.json index 9c900f0..e5b1a67 100644 --- a/locales/en.json +++ b/locales/en.json @@ -122,9 +122,9 @@ "preview": "Preview", "privacy": "Privacy", "reverse-route": "Reverse route", - "route-quality-altitude": "Altitude coding", - "route-quality-cost": "Cost coding", - "route-quality-incline": "Incline coding", + "route-quality-altitude": "Altitude coding (C key to toggle)", + "route-quality-cost": "Cost coding (C key to toggle)", + "route-quality-incline": "Incline coding (C key to toggle)", "strava-biking": "Show Strava biking segments", "strava-running": "Show Strava running segments", "zoomInTitle": "Zoom in (+ key)",