@adrihfly/screen-detector-hook
Version:
A useful react hook for handle screen position and size
18 lines (17 loc) • 663 B
TypeScript
type ModifierKey = keyof Pick<KeyboardEvent, 'ctrlKey' | 'shiftKey' | 'metaKey' | 'altKey'>;
type Shortcut = {
action: (() => void) | (() => Promise<void>);
modifiers: Array<ModifierKey>;
key: string;
description: string;
};
type ShortcutConfig = {
silent?: boolean;
map: Shortcut[];
};
type ShortcutMap = Record<string, Shortcut>;
declare const getEventMapKey: (event: KeyboardEvent) => string;
declare const generateShorcutMap: (map: ShortcutConfig["map"]) => ShortcutMap;
declare const useShortcuts: ({ map, silent }: ShortcutConfig) => void;
export { generateShorcutMap, getEventMapKey, useShortcuts };
export type { ShortcutConfig };