diff --git a/web/src/distancemeasure.ts b/web/src/distancemeasure.ts index d18066d..aa7609e 100644 --- a/web/src/distancemeasure.ts +++ b/web/src/distancemeasure.ts @@ -43,6 +43,8 @@ class DistanceMeasure implements maplibregl.IControl { document.addEventListener('keyup', (e) => { if (e.key === 'Escape' && this._measuring) { this._removeMeasuring() + } else if (e.key === 'm' && !this._isTypingTarget(e.target)) { + this._onClickDistanceMeasure() } }) @@ -59,6 +61,12 @@ class DistanceMeasure implements maplibregl.IControl { this._map = undefined } + _isTypingTarget(target: EventTarget | null): boolean { + if (!(target instanceof HTMLElement)) return false + const tag = target.tagName + return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || target.isContentEditable + } + _onClickDistanceMeasure() { if (this._measuring) { this._removeMeasuring()