@fictjs/use-escape-keydown
v0.3.0
Published
Escape key listener hook for Fict UI primitives.
Maintainers
Readme
@fictjs/use-escape-keydown
Escape-key listener for Fict, modeled after @radix-ui/react-use-escape-keydown. Runs a callback when the user presses Escape, listening on the capture phase so overlays can react first.
Part of ui-primitives, a port of Radix Primitives to Fict.
Installation
pnpm add @fictjs/use-escape-keydown fictUsage
import { useEscapeKeydown } from '@fictjs/use-escape-keydown'
useEscapeKeydown((event) => {
close()
})API
useEscapeKeydown(onEscapeKeyDown, ownerDocument?)— attaches a capture-phasekeydownlistener that callsonEscapeKeyDownon Escape, and cleans it up automatically.ownerDocumentdefaults todocument.
Exports
- Values:
useEscapeKeydown.
Documentation
The API mirrors @radix-ui/react-use-escape-keydown. See the ui-primitives overview and the architecture guide.
License
MIT © Fict contributors.
