import { findMatchedKey } from './keyEvents'; import { View as RNView, TextInputKeyPressEventData } from "react-native"; import { IKeyboardEventHandlerEvent, IKeyboardEventHandlerProps, IKeyboardEventHandlerState } from "./types"; import { Component, RefObject } from 'react'; /** * A React Native implementation of a keyboard event handler. * * This component listens for keyboard events and allows you to define specific keys to handle. * It can be used to create custom keyboard interactions in your application. * * @see https://github.com/linsight/react-keyboard-event-handler for documentation. */ export default class KeyboardEventHandler extends Component, IKeyboardEventHandlerState> { readonly childRef: RefObject; /** * Finds the matched key from a keyboard event based on the provided keys. * * This function takes a keyboard event and an array of keys, and checks if any of the keys * match the event. It also supports key aliases and can return a special value if 'all' is included * in the keys array. * * @param event - The keyboard event to check against the provided keys. * This can be any event object that contains key information. * Example: * ```typescript * const event = { key: 'Enter', type: 'keydown' }; * ``` * @param keys - An array of keys to match against the event. * This can include base keys, modifier keys, or aliases. * Example: * ```typescript * const keys = ['enter', 'space', 'ctrl+a', 'all']; * ``` * * @returns The matched key as an `IKeyboardEventHandlerKey`. * If no key matches and 'all' is included in the keys, it returns 'other'. * If no match is found, it returns `undefined`. * * @example * ```typescript * const event = { key: 'Enter', type: 'keydown' }; * const keys = ['enter', 'space', 'ctrl+a']; * const matchedKey = findMatchedKey(event, keys); * console.log(matchedKey); // Output: 'enter' * ``` * * @example * ```typescript * const event = { key: 'Escape', type: 'keydown' }; * const keys = ['all']; * const matchedKey = findMatchedKey(event, keys); * console.log(matchedKey); // Output: 'other' * ``` */ static findMatchedKey: typeof findMatchedKey; /** * An array of exclusive handlers that are currently registered. */ static exclusiveHandlers: KeyboardEventHandler[]; /** * Default properties for the KeyboardEventHandler component. */ static defaultProps: IKeyboardEventHandlerProps; /** * Creates an instance of KeyboardEventHandler. * * @param props - The properties for the component, including key handling options. */ constructor(props: IKeyboardEventHandlerProps); /** * Checks if the component is a filter. * * @returns A boolean indicating whether the component is a filter. */ isFilter(): boolean | undefined; /** * Lifecycle method that is called after the component updates. * * @param prevProps - The previous properties of the component. * @param prevState - The previous state of the component. * @param snapshot - A snapshot of the component's state before the update. */ componentDidUpdate(prevProps: Readonly>, prevState: Readonly, snapshot?: any): void; /** * Registers the current handler as an exclusive handler. */ registerExclusiveHandler(): void; /** * Deregisters the current handler from the exclusive handlers. */ deregisterExclusiveHandler(): void; /** * Handles keyboard events and checks if they match the specified keys. * * @param event - The keyboard event to handle. * @returns A boolean indicating whether the event was handled successfully. */ handleKeyboardEvent(event: IKeyboardEventHandlerEvent): any; /** * Renders the component and attaches keyboard event handlers. * * @returns A React element representing the keyboard event handler. */ render(): import("react/jsx-runtime").JSX.Element | null; } export * from "./types";