v0.9.0 636c44c

types.ts RawHistoryFolder

1/**
2 * Keyboard Service Types
3 *
4 * Type definitions for the unified keyboard shortcut system.
5 * Provides type-safe interfaces for registering and handling keyboard shortcuts.
6 */
7
8export interface ShortcutConfig {
9  /** The keyboard shortcut key combination (e.g., 'cmdorctrl+l', 'escape', 'enter') */
10  key: string;
11
12  /** Function to execute when the shortcut is triggered */
13  handler: () => void;
14
15  /** Whether to prevent the default browser behavior (default: true) */
16  preventDefault?: boolean;
17
18  /** Whether to stop event propagation (default: true) */
19  stopPropagation?: boolean;
20
21  /** Only trigger when this component is focused (default: false) */
22  whenFocused?: boolean;
23
24  /** Optional description for debugging */
25  description?: string;
26}
27
28export interface KeyboardEventDetail {
29  /** The original keyboard shortcut string */
30  shortcut: string;
31
32  /** Timestamp when the event occurred */
33  timestamp: number;
34
35  /** Component that should handle this event (if specified) */
36  targetComponent?: string;
37}
38
39export interface ComponentShortcuts {
40  /** Unique component identifier */
41  componentId: string;
42
43  /** Array of shortcuts registered by this component */
44  shortcuts: ShortcutConfig[];
45
46  /** Whether this component is currently focused */
47  focused: boolean;
48
49  /** Optional cleanup function called when component is destroyed */
50  cleanup?: () => void;
51}
52
53export interface KeyboardServiceConfig {
54  /** Enable debug logging for keyboard events */
55  debug?: boolean;
56
57  /** Global shortcuts that work regardless of component focus */
58  globalShortcuts?: ShortcutConfig[];
59}
60
61/**
62 * Event types for keyboard service
63 */
64export type KeyboardEventType =
65  | "shortcut-triggered"
66  | "component-focused"
67  | "component-blurred"
68  | "shortcut-registered"
69  | "shortcut-unregistered";
70
71export interface KeyboardEvent {
72  type: KeyboardEventType;
73  detail: KeyboardEventDetail | ComponentShortcuts | ShortcutConfig;
74}
75
76/**
77 * Keyboard modifiers mapping
78 */
79export const MODIFIER_KEYS = {
80  ctrl: "ctrlKey",
81  cmd: "metaKey",
82  cmdorctrl: navigator.platform.includes("Mac") ? "metaKey" : "ctrlKey",
83  alt: "altKey",
84  shift: "shiftKey",
85} as const;
86
87/**
88 * Common shortcut patterns used throughout the application
89 */
90export const COMMON_SHORTCUTS = {
91  OMNIBOX_OPEN: "cmdorctrl+l",
92  FIND_OPEN: "cmdorctrl+f",
93  ESCAPE: "escape",
94  ENTER: "enter",
95  ARROW_UP: "arrowup",
96  ARROW_DOWN: "arrowdown",
97  ARROW_LEFT: "arrowleft",
98  ARROW_RIGHT: "arrowright",
99  TAB: "tab",
100  SHIFT_TAB: "shift+tab",
101} as const;

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