MCPcopy
hub / github.com/github/hotkey / install

Function install

src/index.ts:65–74  ·  view source on GitHub ↗
(element: HTMLElement, hotkey?: string)

Source from the content-addressed store, hash-verified

63}
64
65export function install(element: HTMLElement, hotkey?: string): void {
66 // Install the keydown handler if this is the first install
67 if (Object.keys(hotkeyRadixTrie.children).length === 0) {
68 document.addEventListener('keydown', keyDownHandler)
69 }
70
71 const hotkeys = expandHotkeyToEdges(hotkey || element.getAttribute('data-hotkey') || '')
72 const leaves = hotkeys.map(h => (hotkeyRadixTrie.insert(h) as Leaf<HTMLElement>).add(element))
73 elementsLeaves.set(element, leaves)
74}
75
76export function uninstall(element: HTMLElement): void {
77 const leaves = elementsLeaves.get(element)

Callers 2

setHTMLFunction · 0.90
test.jsFile · 0.90

Calls 3

expandHotkeyToEdgesFunction · 0.85
addMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected