hotkey-router 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- // hotkey-router v0.4.1 | SEE LICENSE IN LICENSE
1
+ // hotkey-router v0.5.0 | SEE LICENSE IN LICENSE
2
2
 
3
3
 
4
4
  // data/browser-hotkeys.json
5
5
  var browser_hotkeys_default = {
6
6
  $comment: "Machine-readable companion to docs/browser-hotkeys.md. Each combo entry describes who claims the binding and how strongly. Intended for runtime conflict warnings in keyboard-routing libraries (e.g. hotkey-router) and dev-time validation in apps like WebRadar. Update both this file and the markdown together \u2014 the markdown is the human source of truth, this file is the machine projection.",
7
7
  version: {
8
- generated: "2026-10-15",
8
+ generated: "2026-10-29",
9
9
  schema: "1.0",
10
10
  sources: [
11
11
  "https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly",
@@ -27,7 +27,8 @@ var browser_hotkeys_default = {
27
27
  "system-text": "Only reserved while a text input has focus (terminal-style cursor controls on macOS).",
28
28
  compose: "macOS Option+letter types a special character in text inputs. Outside inputs, free for page world.",
29
29
  os: "Operating system intercepts globally, before any application sees it.",
30
- "devtools-open": "Only relevant when DevTools is already open; outside DevTools it fires normally."
30
+ "devtools-open": "Only relevant when DevTools is already open; outside DevTools it fires normally.",
31
+ preventable: "The browser's own shortcut, but keydown reaches the page first: a binding with preventDefault() keeps the browser out, and without one the browser acts. Checked with real keys on Windows (docs/notes/key-check-reserved-2026-10-29.md)."
31
32
  },
32
33
  $keyFormat: "Each combo key uses hotkey-router-compatible syntax: modifiers in canonical order (ctrl|meta|alt|shift) joined by '+', then the key (lowercased letter, or symbolic name). Per-platform tables use the platform's native modifier name \u2014 `meta` on macOS = Cmd, `meta` on Windows = Win, `ctrl` on Linux/Windows = the primary modifier.",
33
34
  platforms: {
@@ -172,27 +173,29 @@ var browser_hotkeys_default = {
172
173
  windows: {
173
174
  browsers: {
174
175
  firefox: {
175
- "ctrl+a": { action: "Select all", severity: "hard" },
176
- "ctrl+b": { action: "Bookmarks sidebar", severity: "hard" },
177
- "ctrl+c": { action: "Copy", severity: "hard" },
178
- "ctrl+d": { action: "Bookmark this page", severity: "hard" },
179
- "ctrl+f": { action: "Find in page", severity: "hard" },
180
- "ctrl+g": { action: "Find next", severity: "hard" },
181
- "ctrl+h": { action: "History sidebar", severity: "hard" },
182
- "ctrl+j": { action: "Downloads", severity: "hard" },
183
- "ctrl+l": { action: "Focus address bar", severity: "hard" },
176
+ "ctrl+a": { action: "Select all", severity: "preventable" },
177
+ "ctrl+b": { action: "Bookmarks sidebar", severity: "preventable" },
178
+ "ctrl+c": { action: "Copy", severity: "preventable" },
179
+ "ctrl+d": { action: "Bookmark this page", severity: "preventable" },
180
+ "ctrl+e": { action: "Search from page", severity: "preventable" },
181
+ "ctrl+f": { action: "Find in page", severity: "preventable" },
182
+ "ctrl+g": { action: "Find next", severity: "preventable" },
183
+ "ctrl+h": { action: "History sidebar", severity: "preventable" },
184
+ "ctrl+j": { action: "Downloads", severity: "preventable" },
185
+ "ctrl+k": { action: "Search from page", severity: "preventable" },
186
+ "ctrl+l": { action: "Focus address bar", severity: "preventable" },
184
187
  "ctrl+n": { action: "New window", severity: "hard" },
185
- "ctrl+o": { action: "Open file", severity: "hard" },
186
- "ctrl+p": { action: "Print", severity: "hard" },
187
- "ctrl+r": { action: "Reload", severity: "hard" },
188
- "ctrl+s": { action: "Save page", severity: "hard" },
188
+ "ctrl+o": { action: "Open file", severity: "preventable" },
189
+ "ctrl+p": { action: "Print", severity: "preventable" },
190
+ "ctrl+r": { action: "Reload", severity: "preventable" },
191
+ "ctrl+s": { action: "Save page", severity: "preventable" },
189
192
  "ctrl+t": { action: "New tab", severity: "hard" },
190
- "ctrl+u": { action: "View source", severity: "hard" },
191
- "ctrl+v": { action: "Paste", severity: "hard" },
193
+ "ctrl+u": { action: "View source", severity: "preventable" },
194
+ "ctrl+v": { action: "Paste", severity: "preventable" },
192
195
  "ctrl+w": { action: "Close tab", severity: "hard" },
193
- "ctrl+x": { action: "Cut", severity: "hard" },
194
- "ctrl+y": { action: "Redo", severity: "hard" },
195
- "ctrl+z": { action: "Undo", severity: "hard" },
196
+ "ctrl+x": { action: "Cut", severity: "preventable" },
197
+ "ctrl+y": { action: "Redo", severity: "preventable" },
198
+ "ctrl+z": { action: "Undo", severity: "preventable" },
196
199
  "ctrl+shift+a": { action: "Add-ons manager", severity: "hard" },
197
200
  "ctrl+shift+b": { action: "Bookmarks toolbar", severity: "hard" },
198
201
  "ctrl+shift+c": { action: "Inspector (element picker)", severity: "hard" },
@@ -221,27 +224,27 @@ var browser_hotkeys_default = {
221
224
  "alt+d": { action: "Focus address bar", severity: "hard" }
222
225
  },
223
226
  chrome: {
224
- "ctrl+a": { action: "Select all", severity: "hard" },
225
- "ctrl+c": { action: "Copy", severity: "hard" },
226
- "ctrl+d": { action: "Bookmark this page", severity: "hard" },
227
- "ctrl+e": { action: "Search from page", severity: "hard" },
228
- "ctrl+f": { action: "Find in page", severity: "hard" },
229
- "ctrl+g": { action: "Find next", severity: "hard" },
230
- "ctrl+h": { action: "History page", severity: "hard" },
231
- "ctrl+j": { action: "Downloads", severity: "hard" },
232
- "ctrl+k": { action: "Search from page", severity: "hard" },
233
- "ctrl+l": { action: "Focus address bar", severity: "hard" },
227
+ "ctrl+a": { action: "Select all", severity: "preventable" },
228
+ "ctrl+c": { action: "Copy", severity: "preventable" },
229
+ "ctrl+d": { action: "Bookmark this page", severity: "preventable" },
230
+ "ctrl+e": { action: "Search from page", severity: "preventable" },
231
+ "ctrl+f": { action: "Find in page", severity: "preventable" },
232
+ "ctrl+g": { action: "Find next", severity: "preventable" },
233
+ "ctrl+h": { action: "History page", severity: "preventable" },
234
+ "ctrl+j": { action: "Downloads", severity: "preventable" },
235
+ "ctrl+k": { action: "Search from page", severity: "preventable" },
236
+ "ctrl+l": { action: "Focus address bar", severity: "preventable" },
234
237
  "ctrl+n": { action: "New window", severity: "hard" },
235
- "ctrl+o": { action: "Open file", severity: "hard" },
236
- "ctrl+p": { action: "Print", severity: "hard" },
237
- "ctrl+r": { action: "Reload", severity: "hard" },
238
- "ctrl+s": { action: "Save page", severity: "hard" },
238
+ "ctrl+o": { action: "Open file", severity: "preventable" },
239
+ "ctrl+p": { action: "Print", severity: "preventable" },
240
+ "ctrl+r": { action: "Reload", severity: "preventable" },
241
+ "ctrl+s": { action: "Save page", severity: "preventable" },
239
242
  "ctrl+t": { action: "New tab", severity: "hard" },
240
- "ctrl+u": { action: "View source", severity: "hard" },
241
- "ctrl+v": { action: "Paste", severity: "hard" },
243
+ "ctrl+u": { action: "View source", severity: "preventable" },
244
+ "ctrl+v": { action: "Paste", severity: "preventable" },
242
245
  "ctrl+w": { action: "Close tab", severity: "hard" },
243
- "ctrl+x": { action: "Cut", severity: "hard" },
244
- "ctrl+z": { action: "Undo", severity: "hard" },
246
+ "ctrl+x": { action: "Cut", severity: "preventable" },
247
+ "ctrl+z": { action: "Undo", severity: "preventable" },
245
248
  "ctrl+shift+b": { action: "Bookmarks bar toggle", severity: "hard" },
246
249
  "ctrl+shift+d": { action: "Bookmark all tabs", severity: "hard" },
247
250
  "ctrl+shift+g": { action: "Find previous", severity: "find-bar-only" },
@@ -258,28 +261,28 @@ var browser_hotkeys_default = {
258
261
  "alt+f": { action: "Customize menu (alt)", severity: "menu-activation" }
259
262
  },
260
263
  edge: {
261
- "ctrl+a": { action: "Select all", severity: "hard" },
262
- "ctrl+c": { action: "Copy", severity: "hard" },
263
- "ctrl+d": { action: "Favorite this page", severity: "hard" },
264
- "ctrl+e": { action: "Search from page", severity: "hard" },
265
- "ctrl+f": { action: "Find in page", severity: "hard" },
266
- "ctrl+g": { action: "Find next", severity: "hard" },
267
- "ctrl+h": { action: "History", severity: "hard" },
268
- "ctrl+j": { action: "Downloads", severity: "hard" },
269
- "ctrl+k": { action: "Search from page", severity: "hard" },
270
- "ctrl+l": { action: "Focus address bar", severity: "hard" },
271
- "ctrl+m": { action: "Mute current tab", severity: "hard" },
264
+ "ctrl+a": { action: "Select all", severity: "preventable" },
265
+ "ctrl+c": { action: "Copy", severity: "preventable" },
266
+ "ctrl+d": { action: "Favorite this page", severity: "preventable" },
267
+ "ctrl+e": { action: "Search from page", severity: "preventable" },
268
+ "ctrl+f": { action: "Find in page", severity: "preventable" },
269
+ "ctrl+g": { action: "Find next", severity: "preventable" },
270
+ "ctrl+h": { action: "History", severity: "preventable" },
271
+ "ctrl+j": { action: "Downloads", severity: "preventable" },
272
+ "ctrl+k": { action: "Search from page", severity: "preventable" },
273
+ "ctrl+l": { action: "Focus address bar", severity: "preventable" },
274
+ "ctrl+m": { action: "Mute current tab", severity: "preventable" },
272
275
  "ctrl+n": { action: "New window", severity: "hard" },
273
- "ctrl+o": { action: "Open file", severity: "hard" },
274
- "ctrl+p": { action: "Print", severity: "hard" },
275
- "ctrl+r": { action: "Reload", severity: "hard" },
276
- "ctrl+s": { action: "Save page", severity: "hard" },
276
+ "ctrl+o": { action: "Open file", severity: "preventable" },
277
+ "ctrl+p": { action: "Print", severity: "preventable" },
278
+ "ctrl+r": { action: "Reload", severity: "preventable" },
279
+ "ctrl+s": { action: "Save page", severity: "preventable" },
277
280
  "ctrl+t": { action: "New tab", severity: "hard" },
278
- "ctrl+u": { action: "View source", severity: "hard" },
279
- "ctrl+v": { action: "Paste", severity: "hard" },
281
+ "ctrl+u": { action: "View source", severity: "preventable" },
282
+ "ctrl+v": { action: "Paste", severity: "preventable" },
280
283
  "ctrl+w": { action: "Close tab", severity: "hard" },
281
- "ctrl+x": { action: "Cut", severity: "hard" },
282
- "ctrl+z": { action: "Undo", severity: "hard" },
284
+ "ctrl+x": { action: "Cut", severity: "preventable" },
285
+ "ctrl+z": { action: "Undo", severity: "preventable" },
283
286
  "ctrl+shift+b": { action: "Favorites bar toggle", severity: "hard" },
284
287
  "ctrl+shift+d": { action: "Bookmark all tabs in folder", severity: "hard" },
285
288
  "ctrl+shift+e": { action: "Search in sidebar", severity: "hard" },
@@ -485,7 +488,7 @@ function lookupKey(combo) {
485
488
  // reservations.js
486
489
  var SUPPORTED_SCHEMA = "1.0";
487
490
  var HARD_SEVERITIES = /* @__PURE__ */ new Set(["hard", "os", "menu-activation"]);
488
- var SOFT_SEVERITIES = /* @__PURE__ */ new Set(["find-bar-only", "compose", "system-text", "devtools-open"]);
491
+ var SOFT_SEVERITIES = /* @__PURE__ */ new Set(["find-bar-only", "compose", "system-text", "devtools-open", "preventable"]);
489
492
  function canonicalize(rawKey) {
490
493
  const parts = String(rawKey).toLowerCase().split("+").map((p) => p.trim()).filter(Boolean);
491
494
  if (!parts.length) return "";
@@ -570,15 +573,16 @@ function severityIsHard(severity) {
570
573
  function severityIsSoft(severity) {
571
574
  return SOFT_SEVERITIES.has(severity);
572
575
  }
573
- function formatReservationWarning(reservation, rawHotkey) {
576
+ function formatReservationWarning(reservation, rawHotkey, bindOptions) {
574
577
  const where = platformLabel(reservation.platform);
575
578
  const sourceLabel = reservation.source === "browser" ? `${reservation.browser} on ${where}` : where;
576
- const tag = severityIsHard(reservation.severity) ? "will not fire" : "fires in normal browsing";
579
+ const tag = severityIsHard(reservation.severity) ? "will not fire" : reservation.severity === "preventable" ? bindOptions?.preventDefault ? "fires first; preventDefault keeps the browser out" : "fires, and the browser acts too; bind with preventDefault: true" : "fires in normal browsing";
577
580
  return `[hotkey-router] "${rawHotkey}" (${reservation.lookupKey}) reserved by ${sourceLabel}: "${reservation.action}" [${reservation.severity}] \u2014 ${tag}.`;
578
581
  }
579
- function emitReservationWarning(reservation, rawHotkey, console_ = console) {
580
- const msg = formatReservationWarning(reservation, rawHotkey);
581
- const fn = severityIsHard(reservation.severity) ? console_.warn : console_.info;
582
+ function emitReservationWarning(reservation, rawHotkey, console_ = console, bindOptions) {
583
+ const msg = formatReservationWarning(reservation, rawHotkey, bindOptions);
584
+ const loud = severityIsHard(reservation.severity) || reservation.severity === "preventable" && !bindOptions?.preventDefault;
585
+ const fn = loud ? console_.warn : console_.info;
582
586
  fn.call(console_, msg);
583
587
  }
584
588
  function installReservationWarnings(hotkeys, opts = {}) {
@@ -594,7 +598,7 @@ function installReservationWarnings(hotkeys, opts = {}) {
594
598
  if (options?.warnOnReserved === false) return;
595
599
  if (!platform || !browser) return;
596
600
  const reservation = lookupReservation(combo, { platform, browser });
597
- if (reservation) emitReservationWarning(reservation, raw, console_);
601
+ if (reservation) emitReservationWarning(reservation, raw, console_, options);
598
602
  });
599
603
  }
600
604
  var SCHEMA_VERSION = browser_hotkeys_default?.version?.schema;