UNPKG

react-elegant-ui

Version:

Elegant UI components, made by BEM best practices for react

37 lines (36 loc) 1.16 kB
export type KeyboardKeys = string; export type Keys = Record<KeyboardKeys, string | string[]>; export type KeyCodesList = readonly (KeyboardKeys | readonly KeyboardKeys[])[]; /** * Dictionary contains popular key codes * * It should use with `code` property with native event, * but usually it will work with `key` property of react synthetic event */ export declare const Keys: { readonly ENTER: readonly ["Enter", "NumpadEnter"]; readonly SPACE: "Space"; readonly ESC: "Escape"; readonly TAB: "Tab"; readonly UP: "ArrowUp"; readonly DOWN: "ArrowDown"; readonly LEFT: "ArrowLeft"; readonly RIGHT: "ArrowRight"; readonly HOME: "Home"; readonly END: "End"; readonly PAGE_UP: "PageUp"; readonly PAGE_DOWN: "PageDown"; readonly CAPS_LOCK: "CapsLock"; }; /** * Check key code to match * * It useful to abstract from real key codes and replace it to constants * * @example * isKeyCode(event.code, [Keys.ESC, Keys.ENTER]) * * @param code Key code. * @param keys List of keys as numbers or strings. */ export declare function isKeyCode(code: string, keys: KeyCodesList | KeyboardKeys): boolean;