UNPKG

661 BTypeScriptView Raw
1import type { BasicTarget } from '../utils/domTarget';
2export type KeyType = number | string;
3export type KeyPredicate = (event: KeyboardEvent) => KeyType | boolean | undefined;
4export type KeyFilter = KeyType | KeyType[] | ((event: KeyboardEvent) => boolean);
5export type KeyEvent = 'keydown' | 'keyup';
6export type Target = BasicTarget<HTMLElement | Document | Window>;
7export type Options = {
8 events?: KeyEvent[];
9 target?: Target;
10 exactMatch?: boolean;
11 useCapture?: boolean;
12};
13declare function useKeyPress(keyFilter: KeyFilter, eventHandler: (event: KeyboardEvent, key: KeyType) => void, option?: Options): void;
14export default useKeyPress;
15
\No newline at end of file