Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for 'keydown' and 'keyup' events #6421

Merged
merged 2 commits into from Jan 14, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/map/Map.js
Expand Up @@ -1316,9 +1316,15 @@ export var Map = Evented.extend({
// this event. Also fired on mobile when the user holds a single touch
// for a second (also called long press).
// @event keypress: KeyboardEvent
// Fired when the user presses a key from the keyboard while the map is focused.
// Fired when the user presses a key from the keyboard that produces a character value while the map is focused.
// @event keydown: KeyboardEvent
// Fired when the user presses a key from the keyboard while the map is focused. Unlike the `keypress` event,
// the `keydown` event is fired for keys that produce a character value and for keys
// that do not produce a character value.
// @event keyup: KeyboardEvent
// Fired when the user releases a key from the keyboard while the map is focused.
onOff(this._container, 'click dblclick mousedown mouseup ' +
'mouseover mouseout mousemove contextmenu keypress', this._handleDOMEvent, this);
'mouseover mouseout mousemove contextmenu keypress keydown keyup', this._handleDOMEvent, this);

if (this.options.trackResize) {
onOff(window, 'resize', this._onResize, this);
Expand Down Expand Up @@ -1382,7 +1388,7 @@ export var Map = Evented.extend({

var type = e.type;

if (type === 'mousedown' || type === 'keypress') {
if (type === 'mousedown' || type === 'keypress' || type === 'keyup' || type === 'keydown') {
// prevents outline when clicking on keyboard-focusable element
DomUtil.preventOutline(e.target || e.srcElement);
}
Expand Down Expand Up @@ -1421,7 +1427,7 @@ export var Map = Evented.extend({
originalEvent: e
};

if (e.type !== 'keypress') {
if (e.type !== 'keypress' && e.type !== 'keydown' && e.type !== 'keyup') {
var isMarker = target.getLatLng && (!target._radius || target._radius <= 10);
data.containerPoint = isMarker ?
this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e);
Expand Down