useEscapeKey
A hook for detecting escape key presses.
Installation
npx shadcn add https://darwin-ui.mandalsuraj.com/registry/use-escape-key.jsonUsage
import { useEscapeKey } from '@smc/darwin-ui';
export function Modal({ onClose }) { useEscapeKey(onClose);
return ( <div className="modal"> Press ESC to close </div> );}API Reference
function useEscapeKey(callback: () => void): void;| Parameter | Type | Description |
|---|---|---|
callback | () => void | Function called on ESC press |