MCPcopy
hub / github.com/CapSoftware/Cap / createKeyDownSignal

Function createKeyDownSignal

apps/desktop/src/utils/events.ts:16–35  ·  view source on GitHub ↗
(
	element: HTMLElement | Window,
	key: string,
)

Source from the content-addressed store, hash-verified

14}
15
16export function createKeyDownSignal(
17 element: HTMLElement | Window,
18 key: string,
19) {
20 const [isDown, setDown] = createSignal(false);
21
22 createEventListenerMap(element, {
23 keydown: (e) => {
24 if (e.key === key) setDown(true);
25 },
26 keyup: (e) => {
27 if (e.key === key) setDown(false);
28 },
29 blur: () => {
30 setDown(false);
31 },
32 });
33
34 return isDown;
35}

Callers 1

CropperFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected