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

Function App

examples/solid/createHotkeySequences/src/index.tsx:15–342  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13import './index.css'
14
15function App() {
16 const [lastSequence, setLastSequence] = createSignal<string | null>(null)
17 const [history, setHistory] = createSignal<Array<string>>([])
18 const [helloSequenceEnabled, setHelloSequenceEnabled] = createSignal(true)
19 const addToHistory = (action: string) => {
20 setLastSequence(action)
21 setHistory((h) => [...h.slice(-9), action])
22 }
23
24 createHotkeySequences([
25 {
26 sequence: ['G', 'G'],
27 callback: () => addToHistory('gg \u2192 Go to top'),
28 options: {
29 meta: {
30 name: 'Go to top',
31 description: 'Scroll to the beginning of the document',
32 },
33 },
34 },
35 {
36 sequence: ['Shift+G'],
37 callback: () => addToHistory('G \u2192 Go to bottom'),
38 options: {
39 meta: {
40 name: 'Go to bottom',
41 description: 'Scroll to the end of the document',
42 },
43 },
44 },
45 {
46 sequence: ['D', 'D'],
47 callback: () => addToHistory('dd \u2192 Delete line'),
48 options: {
49 meta: {
50 name: 'Delete line',
51 description: 'Delete the current line',
52 },
53 },
54 },
55 {
56 sequence: ['Y', 'Y'],
57 callback: () => addToHistory('yy \u2192 Yank (copy) line'),
58 options: {
59 meta: {
60 name: 'Yank line',
61 description: 'Copy the current line to clipboard',
62 },
63 },
64 },
65 {
66 sequence: ['D', 'W'],
67 callback: () => addToHistory('dw \u2192 Delete word'),
68 options: {
69 meta: {
70 name: 'Delete word',
71 description: 'Delete from cursor to end of word',
72 },

Callers

nothing calls this directly

Calls 3

createHotkeySequencesFunction · 0.90
createHotkeyFunction · 0.90
addToHistoryFunction · 0.70

Tested by

no test coverage detected