mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
Shouls support JS convention: https://craig.is/killing/mice#:~:text=As%20a%20convenience%20you%20can%20also%20return%20false%20in%20your%20callback Thanks! /cc @brunnre8 Fixes #63233
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
// Type definitions for Mousetrap 1.6
|
|
// Project: http://craig.is/killing/mice
|
|
// Definitions by: Dániel Tar <https://github.com/qcz>
|
|
// Alan Choi <https://github.com/alanhchoi>
|
|
// Nic Barker <https://github.com/nicbarker>
|
|
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
declare namespace Mousetrap {
|
|
interface ExtendedKeyboardEvent extends KeyboardEvent {
|
|
returnValue: boolean; // IE returnValue
|
|
}
|
|
|
|
interface MousetrapStatic {
|
|
(el?: Element): MousetrapInstance;
|
|
new (el?: Element): MousetrapInstance;
|
|
addKeycodes(keycodes: { [key: number]: string }): void;
|
|
stopCallback: (e: ExtendedKeyboardEvent, element: Element, combo: string) => boolean;
|
|
bind(
|
|
keys: string | string[],
|
|
callback: (e: ExtendedKeyboardEvent, combo: string) => boolean | void,
|
|
action?: string,
|
|
): MousetrapInstance;
|
|
unbind(keys: string | string[], action?: string): MousetrapInstance;
|
|
trigger(keys: string, action?: string): MousetrapInstance;
|
|
reset(): MousetrapInstance;
|
|
}
|
|
|
|
interface MousetrapInstance {
|
|
stopCallback: (e: ExtendedKeyboardEvent, element: Element, combo: string) => boolean;
|
|
bind(
|
|
keys: string | string[],
|
|
callback: (e: ExtendedKeyboardEvent, combo: string) => void,
|
|
action?: string,
|
|
): this;
|
|
unbind(keys: string | string[], action?: string): this;
|
|
trigger(keys: string, action?: string): this;
|
|
handleKey(character: string, modifiers: string[], e: ExtendedKeyboardEvent): void;
|
|
reset(): this;
|
|
}
|
|
}
|
|
|
|
declare const Mousetrap: Mousetrap.MousetrapStatic;
|
|
|
|
export = Mousetrap;
|
|
|
|
export as namespace Mousetrap;
|