v0.11.0 dc50343

controls.ts RawHistoryFolder

1/**
2 * Browser Controls Module
3 *
4 * Provides global keyboard and mouse controls that work on all domains.
5 * Only includes essential controls that can work cross-origin:
6 * - Navigation (back/forward)
7 * - Mouse navigation buttons
8 *
9 * Zoom controls are handled natively by the GTK backend
10 */
11
12export interface ControlsConfig {
13  // Future configuration options can be added here
14  _placeholder?: never; // Prevent empty interface warning
15}
16
17let controlsInitialized = false;
18
19export function initializeControls(_config?: ControlsConfig): void {
20  if (controlsInitialized) {
21    console.log("🔄 Browser controls already initialized, skipping");
22    return;
23  }
24
25  console.log("🚀 Initializing browser controls on:", window.location.href);
26
27  // Keyboard event handler for global controls
28  function handleKeyboardEvent(event: KeyboardEvent): void {
29    const { altKey, key } = event;
30    // Note: ctrlKey, metaKey reserved for future use
31
32    try {
33      // Navigation: Alt + Left Arrow (Back)
34      if (altKey && key === "ArrowLeft") {
35        event.preventDefault();
36        event.stopPropagation();
37
38        if (window.history.length > 1) {
39          console.log("⬅️ Navigating back");
40          window.history.back();
41        }
42        return;
43      }
44
45      // Navigation: Alt + Right Arrow (Forward)
46      if (altKey && key === "ArrowRight") {
47        event.preventDefault();
48        event.stopPropagation();
49
50        console.log("➡️ Navigating forward");
51        window.history.forward();
52        return;
53      }
54    } catch (error) {
55      console.error("❌ Error in keyboard handler:", error);
56    }
57  }
58
59  // Mouse event handler for navigation buttons
60  function handleMouseEvent(event: MouseEvent): void {
61    try {
62      // Mouse button 3 (back button)
63      if (event.button === 3) {
64        event.preventDefault();
65        event.stopPropagation();
66
67        if (window.history.length > 1) {
68          console.log("⬅️ Mouse back button pressed");
69          window.history.back();
70        }
71        return;
72      }
73
74      // Mouse button 4 (forward button)
75      if (event.button === 4) {
76        event.preventDefault();
77        event.stopPropagation();
78
79        console.log("➡️ Mouse forward button pressed");
80        window.history.forward();
81        return;
82      }
83    } catch (error) {
84      console.error("❌ Error in mouse handler:", error);
85    }
86  }
87
88  // Add event listeners with high priority (capture phase)
89  try {
90    document.addEventListener("keydown", handleKeyboardEvent, true);
91    document.addEventListener("mousedown", handleMouseEvent, true);
92
93    controlsInitialized = true;
94    console.log("✅ Browser controls initialized");
95
96    // Cleanup function for when page is unloaded
97    window.addEventListener("beforeunload", () => {
98      document.removeEventListener("keydown", handleKeyboardEvent, true);
99      document.removeEventListener("mousedown", handleMouseEvent, true);
100      controlsInitialized = false;
101      console.log("🧹 Browser controls cleaned up");
102    });
103  } catch (error) {
104    console.error("❌ Failed to initialize browser controls:", error);
105  }
106}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close