rooks
Version:
Collection of awesome react hooks
30 lines (29 loc) • 931 B
TypeScript
export interface UseOnStartTypingOptions {
/**
* Whether to trigger for a-z/A-Z keys.
* @default true
*/
includeAZ?: boolean;
/**
* Whether to trigger for 0-9 keys.
* @default false
*/
includeNumbers?: boolean;
}
/**
* Calls the callback when the user starts typing (keydown) outside editable fields.
* @param callback Function to call on valid keydown
* @param {UseOnStartTypingOptions} options Options to control which keys trigger the callback
* @returns void
* @see https://github.com/imbhargav5/rooks
* @example
* useOnStartTyping((event) => {
* console.log('Started typing:', event.key);
* });
*
* @example
* useOnStartTyping((event) => {
* console.log('Number typed:', event.key);
* }, { includeAZ: false, includeNumbers: true });
*/
export declare function useOnStartTyping(callback: (event: KeyboardEvent) => void, options?: UseOnStartTypingOptions): void;