UNPKG

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