mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-07 23:37:35 +08:00
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
// Type definitions for is-hotkey 0.1
|
|
// Project: https://github.com/ianstormtaylor/is-hotkey#readme
|
|
// Definitions by: Pierre-Marc Airoldi <https://github.com/petester42>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
export interface HotKeyOptions {
|
|
byKey: boolean;
|
|
}
|
|
|
|
export interface HotKey {
|
|
which?: number;
|
|
key?: string;
|
|
altKey: boolean;
|
|
ctrlKey: boolean;
|
|
metaKey: boolean;
|
|
shiftKey: boolean;
|
|
}
|
|
|
|
/**
|
|
* Is hotkey?
|
|
*/
|
|
export function isHotkey(
|
|
hotkey: string,
|
|
options?: HotKeyOptions
|
|
): (event: KeyboardEvent) => boolean;
|
|
|
|
export function isHotkey(
|
|
hotkey: string,
|
|
options?: HotKeyOptions | KeyboardEvent,
|
|
event?: KeyboardEvent
|
|
): boolean;
|
|
|
|
export function isCodeHotkey(hotkey: string): (event: KeyboardEvent) => boolean;
|
|
export function isCodeHotkey(hotkey: string, event: KeyboardEvent): boolean;
|
|
|
|
export function isKeyHotkey(hotkey: string): (event: KeyboardEvent) => boolean;
|
|
export function isKeyHotkey(hotkey: string, event: KeyboardEvent): boolean;
|
|
|
|
/**
|
|
* Parse.
|
|
*/
|
|
export function parseHotkey(hotkey: string, options?: HotKeyOptions): HotKey;
|
|
|
|
/**
|
|
* Compare.
|
|
*/
|
|
export function compareHotkey(object: HotKey, event: KeyboardEvent): boolean;
|
|
|
|
/**
|
|
* Utils.
|
|
*/
|
|
export function toKeyCode(name: string): number;
|
|
export function toKeyName(name: string): string;
|
|
|
|
/**
|
|
* Export.
|
|
*/
|
|
export default isHotkey;
|