MCPcopy Create free account
hub / github.com/TanStack/hotkeys / AppComponent

Class AppComponent

examples/angular/injectHotkeys/src/app/app.component.ts:22–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20 templateUrl: './app.component.html',
21})
22export class AppComponent {
23 fd = (h: string) => formatForDisplay(h as Hotkey)
24
25 // Basic demo
26 log = signal<string[]>([])
27 saveCount = signal(0)
28 undoCount = signal(0)
29 redoCount = signal(0)
30
31 // Common options demo
32 commonEnabled = signal(true)
33 counts = signal({ a: 0, b: 0, c: 0 })
34
35 // Dynamic demo
36 nextId = 0
37 shortcuts = signal<DynamicShortcut[]>([
38 {
39 id: this.nextId++,
40 hotkey: 'Shift+A',
41 label: 'Action A',
42 description: 'First dynamic action',
43 count: 0,
44 },
45 {
46 id: this.nextId++,
47 hotkey: 'Shift+B',
48 label: 'Action B',
49 description: 'Second dynamic action',
50 count: 0,
51 },
52 {
53 id: this.nextId++,
54 hotkey: 'Shift+C',
55 label: 'Action C',
56 description: 'Third dynamic action',
57 count: 0,
58 },
59 ])
60 newHotkey = signal('')
61 newLabel = signal('')
62 newDescription = signal('')
63
64 // Registrations viewer
65 readonly registrations = injectHotkeyRegistrations()
66
67 constructor() {
68 // Basic multi-hotkey with meta
69 injectHotkeys([
70 {
71 hotkey: 'Shift+S',
72 callback: (_e, { hotkey }) => {
73 this.saveCount.update((c) => c + 1)
74 this.log.update((l) => [`${hotkey} pressed`, ...l].slice(0, 20))
75 },
76 options: {
77 meta: { name: 'Save', description: 'Save the current document' },
78 },
79 },

Callers

nothing calls this directly

Calls 2

formatForDisplayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…