diff --git a/types/mousetrap/index.d.ts b/types/mousetrap/index.d.ts index b94b475763..541d680654 100644 --- a/types/mousetrap/index.d.ts +++ b/types/mousetrap/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Mousetrap 1.6.x // Project: http://craig.is/killing/mice -// Definitions by: Dániel Tar , Alan Choi , Nic Barker +// Definitions by: Dániel Tar , Alan Choi , Nic Barker , Mitsuka Hanakura a.k.a ragg // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -13,10 +13,10 @@ interface MousetrapStatic { 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) => any, action?: string): void; - unbind(keys: string|string[], action?: string): void; - trigger(keys: string, action?: string): void; - reset(): void; + bind(keys: string|string[], callback: (e: ExtendedKeyboardEvent, combo: string) => any, action?: string): MousetrapInstance; + unbind(keys: string|string[], action?: string): MousetrapInstance; + trigger(keys: string, action?: string): MousetrapInstance; + reset(): MousetrapInstance; /** https://craig.is/killing/mice#extensions.global */ bindGlobal(keyArray: string|string[], callback: (e: ExtendedKeyboardEvent, combo: string) => any, action?: string): void; @@ -24,11 +24,11 @@ interface MousetrapStatic { interface MousetrapInstance { stopCallback: (e: ExtendedKeyboardEvent, element: Element, combo: string) => boolean; - bind(keys: string|string[], callback: (e: ExtendedKeyboardEvent, combo: string) => any, action?: string): void; - unbind(keys: string|string[], action?: string): void; - trigger(keys: string, action?: string): void; + bind(keys: string|string[], callback: (e: ExtendedKeyboardEvent, combo: string) => any, 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(): void; + reset(): this; } declare var Mousetrap: MousetrapStatic; diff --git a/types/mousetrap/test/index.ts b/types/mousetrap/test/index.ts index c1477e5e5b..44aef700c0 100644 --- a/types/mousetrap/test/index.ts +++ b/types/mousetrap/test/index.ts @@ -1,8 +1,9 @@ /// -Mousetrap.bind('4', function() { console.log('4'); }); -Mousetrap.bind("?", function() { console.log('show shortcuts!'); }); -Mousetrap.bind('esc', function() { console.log('escape'); }, 'keyup'); +Mousetrap + .bind('4', function() { console.log('4'); }) + .bind("?", function() { console.log('show shortcuts!'); }) + .bind('esc', function() { console.log('escape'); }, 'keyup'); // combinations Mousetrap.bind('command+shift+K', function() { console.log('command shift k'); });