(element: HTMLElement, hotkey?: string)
| 63 | } |
| 64 | |
| 65 | export 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 | |
| 76 | export function uninstall(element: HTMLElement): void { |
| 77 | const leaves = elementsLeaves.get(element) |
no test coverage detected