From 967d27166744b9b37c192324fa41621128ada477 Mon Sep 17 00:00:00 2001 From: vcoppe Date: Wed, 4 Jun 2025 18:41:28 +0200 Subject: [PATCH] simplify shift key detection --- .../src/lib/components/gpx-layer/GPXLayer.ts | 31 +------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/website/src/lib/components/gpx-layer/GPXLayer.ts b/website/src/lib/components/gpx-layer/GPXLayer.ts index 5a1bdeff..b27e5285 100644 --- a/website/src/lib/components/gpx-layer/GPXLayer.ts +++ b/website/src/lib/components/gpx-layer/GPXLayer.ts @@ -56,31 +56,6 @@ function decrementColor(color: string) { } } -const inspectKey = 'Shift'; -let inspectKeyDown: KeyDown | null = null; -class KeyDown { - key: string; - down: boolean = false; - constructor(key: string) { - this.key = key; - document.addEventListener('keydown', this.onKeyDown); - document.addEventListener('keyup', this.onKeyUp); - } - onKeyDown = (e: KeyboardEvent) => { - if (e.key === this.key) { - this.down = true; - } - }; - onKeyUp = (e: KeyboardEvent) => { - if (e.key === this.key) { - this.down = false; - } - }; - isDown() { - return this.down; - } -} - function getMarkerForSymbol(symbol: string | undefined, layerColor: string) { let symbolSvg = symbol ? symbols[symbol]?.iconSvg : undefined; return ` @@ -163,10 +138,6 @@ export class GPXLayer { this.draggable = get(currentTool) === Tool.WAYPOINT; this.map.on('style.import.load', this.updateBinded); - - if (inspectKeyDown === null) { - inspectKeyDown = new KeyDown(inspectKey); - } } update() { @@ -466,7 +437,7 @@ export class GPXLayer { } layerOnMouseMove(e: any) { - if (inspectKeyDown?.isDown()) { + if (e.originalEvent.shiftKey) { let trackIndex = e.features[0].properties.trackIndex; let segmentIndex = e.features[0].properties.segmentIndex;