UNPKG

pyb-ts

Version:

PYB-CLI - Minimal AI Agent with multi-model support and CLI interface

27 lines (26 loc) 711 B
import { useInput } from "ink"; import { useDoublePress } from "./useDoublePress.js"; import { useState } from "react"; function useExitOnCtrlCD(onExit) { const [exitState, setExitState] = useState({ pending: false, keyName: null }); const handleCtrlC = useDoublePress( (pending) => setExitState({ pending, keyName: "Ctrl-C" }), onExit ); const handleCtrlD = useDoublePress( (pending) => setExitState({ pending, keyName: "Ctrl-D" }), onExit ); useInput((input, key) => { if (key.ctrl && input === "c") handleCtrlC(); if (key.ctrl && input === "d") handleCtrlD(); }); return exitState; } export { useExitOnCtrlCD }; //# sourceMappingURL=useExitOnCtrlCD.js.map