duoyun-ui
Version:
A lightweight desktop UI component library, implemented using Gem
44 lines • 1.58 kB
TypeScript
export type Key = {
win?: string;
mac?: string;
macSymbol?: string;
alias?: string;
symbol?: string;
};
type NormalizeKey = string;
/**
* @see
* https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values
*/
export declare function normalizeKey(code: string): NormalizeKey;
export declare const isMac: boolean;
/**Get the platform button */
export declare function getDisplayKey(code: string, type?: keyof Key): string;
/**Custom key map */
export declare function setKeys(keysRecord: Record<NormalizeKey, Key>): void;
/**Detect whether the current keyboard event matches the specified button */
export declare function matchHotKey(evt: KeyboardEvent, hotkey: string): string | boolean;
export type HotKeyHandles = {
onLock?: (evt: KeyboardEvent) => void;
onUnlock?: (evt: KeyboardEvent) => void;
onUncapture?: (evt: KeyboardEvent) => void;
[index: string]: ((evt: KeyboardEvent) => void) | undefined;
};
/**Release the lock state of the continuous button, see `hotkeys` */
export declare function unlock(): void;
type HotkeysOptions = {
stopPropagation?: boolean;
preventDefault?: boolean;
};
/**
* Must have non-control character;
* Not case sensitive;
* Support `a-b`, press `a`, hotkeys be locked, wait next `keydown` event, allow call `unlock`
*/
export declare function hotkeys(handles: HotKeyHandles, options?: HotkeysOptions): (event: KeyboardEvent) => void;
/**
* Support space,enter
*/
export declare const commonHandle: (event: KeyboardEvent) => void;
export {};
//# sourceMappingURL=hotkeys.d.ts.map