Files
DefinitelyTyped/types/is-hotkey/index.d.ts
2018-02-12 21:01:41 -05:00

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;