Skip to content

Commit

Permalink
open popup on a marker from keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewharvey committed Jun 19, 2018
1 parent 8cf4624 commit de3b21b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ui/marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@ export default class Marker extends Evented {
}
this._popup = popup;
if (this._lngLat) this._popup.setLngLat(this._lngLat);

this._element.addEventListener('keypress', (e) => {
const code = e.charCode || e.keyCode;

if ((code === 32) || (code === 13)) { // space or enter
this.togglePopup();
}
}.bind(this));
}

return this;
Expand Down

0 comments on commit de3b21b

Please sign in to comment.