bash
npm install @hua-labs/huatsx
import { useKeyboardToggle } from "@hua-labs/hua/framework";tsx
import { useKeyboardToggle } from "@hua-labs/hua/framework";
const { isToggled, toggle } = useKeyboardToggle({
key: 'j',
modifiers: ['ctrl'], // 'ctrl' | 'shift' | 'alt' | 'meta'
preventDefault: true,
});
// isToggled changes when Ctrl+J is pressed
return (
<CommandPalette isOpen={isToggled} onClose={toggle} />
);Ctrl+J
F
Esc
| key | string | - | |
| modifiers | ("ctrl" | "shift" | "alt" | "meta")[] | [] | |
| preventDefault | boolean | true | |
| enabled | boolean | true | |
| ignoreInputs | boolean | true |
| isToggled | boolean | |
| toggle | () => void | |
| setToggled | (value: boolean) => void | |
| enable | () => void | |
| disable | () => void | |
| isEnabled | boolean | |
| mounted | boolean |