Skip to content

useInput

function useInput(handler, deps?): void;

Subscribe to raw keyboard input.

The handler is called for every key press that is not consumed by a focused input handler or a priority Keybind. This is the lowest-level input hook — prefer Keybind for simple shortcuts and component-level handlers for focused input.

ParameterTypeDefault valueDescription
handler(key) => voidundefinedCallback receiving the parsed Key.
depsany[][]Dependency array (same semantics as useEffect).

void

useInput((key) => {
if (key.name === "q" && !key.ctrl) exit();
});