import { KeyboardCodeType } from '../../types/ui.type'; import { Nullable } from '../../types/general'; export declare type KeyboardEventListener = { keyCode: KeyboardCodeType | KeyboardCodeType[]; activeElementInScope?: HTMLElement[] | (() => HTMLElement[]); activeElementOutScope?: HTMLElement[] | (() => HTMLElement[]); eventName?: 'keyup' | 'keydown'; callback: (event: KeyboardEvent) => void; modifierPressed?: Nullable; shiftKey?: Nullable; preventDefault?: boolean; }; /** * It listens to the keyup event on the window and calls the appropriate method on the registered elements * * @property {KeyboardEventListener[]} listeners used to record listeners */ declare class KeyboardManager { private listeners; /** * Manager init */ constructor(); /** * Add the given listener to the list of listeners. * * @param {KeyboardEventListener[]} listeners - The listener to register. * @returns {void} */ register(listeners: KeyboardEventListener[]): void; /** * The function removes the listeners from the listeners array * * @param {KeyboardEventListener[]} listeners - KeyboardEventListener[] * @returns {void} */ deregister(listeners: KeyboardEventListener[]): void; /** * > Listen for keyup events on the window, and if the code matches the keyCode of a listener, * invoke the listener's callback */ private listenKeyPress; /** * We filter the listeners by the event name, then filter them by whether the key code matches the * listener's key code, and then invoke the callback function for each listener that matches * * @param {'keyup' | 'keydown'} eventName - The name of the event that was triggered. * @param {KeyboardEvent} event - KeyboardEvent - this is the event that is passed to the event * listener. */ private invokeListeners; /** * > If the keyCode is accepted, and the activeElement is in the scope, and the activeElement is not * out of the scope, then invoke the listener * * @param {KeyboardEventListener} listener - KeyboardEventListener - the listener object that we're * checking * @param {KeyboardEvent} event - The keyboard event that triggered the listener. * @returns {boolean} - should invoke */ private shouldInvokeListener; /** * Checks if the platform modifier key (Meta on Mac, Ctrl on Windows) is pressed. * * @param {KeyboardEvent} e - The keyboard event to check. * @returns {boolean} - True if the platform modifier key is pressed, false otherwise. */ private isModifierPressed; } declare const _default: KeyboardManager; export default _default;