PageSourceSearch

https://woladen.de/map-keyboard.mjs?v=20260618-keyboard-restore

js woladen.de collected 2026-10-02 01:52:23 UTC 1,923 bytes, 61 lines download raw bytes

1export const MAP_KEYBOARD_PAN_PIXELS = 180;
2
3export function getMapKeyboardAction(key, options = {}) {
4  const panPixels = Number.isFinite(Number(options.panPixels))
5    ? Number(options.panPixels)
6    : MAP_KEYBOARD_PAN_PIXELS;
7  const normalizedKey = normalizeMapKeyboardKey(key);
8
9  if (normalizedKey === "a") {
10    return { type: "pan", direction: "west", x: -panPixels, y: 0 };
11  }
12  if (normalizedKey === "s") {
13    return { type: "pan", direction: "south", x: 0, y: panPixels };
14  }
15  if (normalizedKey === "w") {
16    return { type: "pan", direction: "north", x: 0, y: -panPixels };
17  }
18  if (normalizedKey === "d") {
19    return { type: "pan", direction: "east", x: panPixels, y: 0 };
20  }
21  if (normalizedKey === "q") {
22    return { type: "zoom", direction: "in", delta: 1 };
23  }
24  if (normalizedKey === "e") {
25    return { type: "zoom", direction: "out", delta: -1 };
26  }
27  if (normalizedKey === " " || normalizedKey === "space" || normalizedKey === "spacebar") {
28    return { type: "search" };
29  }
30  return null;
31}
32
33export function performMapKeyboardAction(action, map, callbacks = {}) {
34  if (!action || !map) {
35    return false;
36  }
37  if (action.type === "pan" && typeof map.panBy === "function") {
38    map.panBy([action.x, action.y], { animate: true, duration: 0.15 });
39    return true;
40  }
41  if (action.type === "zoom" && action.delta > 0 && typeof map.zoomIn === "function") {
42    map.zoomIn(action.delta, { animate: true });
43    return true;
44  }
45  if (action.type === "zoom" && action.delta < 0 && typeof map.zoomOut === "function") {
46    map.zoomOut(Math.abs(action.delta), { animate: true });
47    return true;
48  }
49  if (action.type === "search" && typeof callbacks.focusSearchInput === "function") {
50    callbacks.focusSearchInput();
51    return true;
52  }
53  return false;
54}
55
56function normalizeMapKeyboardKey(key) {
57  if (key === " ") {
58    return " ";
59  }
60  return String(key || "").trim().toLowerCase();
61}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.