diff --git a/index.html b/index.html index d857a1c..d7bcc24 100644 --- a/index.html +++ b/index.html @@ -910,6 +910,8 @@ id="elevation-btn" aria-expanded="false" aria-label="Toggle elevation chart" + data-i18n="[title]footer.elevation-chart" + title="Toggle elevation chart" > diff --git a/js/plugin/Elevation.js b/js/plugin/Elevation.js index a23e601..1c827f0 100644 --- a/js/plugin/Elevation.js +++ b/js/plugin/Elevation.js @@ -7,7 +7,10 @@ BR.Elevation = L.Control.Elevation.extend({ bottom: 30, left: 60 }, - theme: 'steelblue-theme' + theme: 'steelblue-theme', + shortcut: { + toggle: 69 // char code for 'e' + } }, onAdd: function(map) { @@ -30,6 +33,8 @@ BR.Elevation = L.Control.Elevation.extend({ L.DomEvent.on(this._container, 'mouseup', this._dragEndHandler, this); } + L.DomEvent.addListener(document, 'keydown', this._keydownListener, this); + return container; }, @@ -64,5 +69,11 @@ BR.Elevation = L.Control.Elevation.extend({ layer.on('mouseout', this._hidePositionMarker.bind(this)); } + }, + + _keydownListener: function(e) { + if (BR.Util.keyboardShortcutsAllowed(e) && e.keyCode === this.options.shortcut.toggle) { + $('#elevation-btn').click(); + } } }); diff --git a/locales/en.json b/locales/en.json index 0ed5eda..73e29f0 100644 --- a/locales/en.json +++ b/locales/en.json @@ -42,6 +42,7 @@ "ascend": "Ascend", "cost": "Cost", "distance": "Distance", + "elevation-chart": "Toggle elevation chart (E key)", "energy-per-100km": "Energy per 100 km", "hours": "hours", "hours-abbrev": "h",