Add Mousetrap.addKeycodes from 1.6

This commit is contained in:
Patrick Lee
2017-12-19 15:47:30 +11:00
parent 571e108a79
commit 53847ce07d
2 changed files with 6 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
// Type definitions for Mousetrap 1.5.x
// Type definitions for Mousetrap 1.6.x
// Project: http://craig.is/killing/mice
// Definitions by: Dániel Tar <https://github.com/qcz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -11,6 +11,7 @@ interface ExtendedKeyboardEvent extends KeyboardEvent {
interface MousetrapStatic {
(el: Element): MousetrapInstance;
new (el: Element): MousetrapInstance;
addKeycodes({ [key: number]: string });
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;

View File

@@ -39,6 +39,10 @@ Mousetrap.unbind('?');
Mousetrap.trigger('esc');
Mousetrap.trigger('esc', 'keyup');
// Test that custom keycodes can be added.
Mousetrap.addKeycodes({ 144: 'numlock' });
Mousetrap.bind('numlock', function() { console.log('numlock'); });
Mousetrap.reset();
// Test that we can create an instance of mousetrap and attach the