mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-06 20:46:50 +08:00
Add Mousetrap.addKeycodes from 1.6
This commit is contained in:
3
types/mousetrap/index.d.ts
vendored
3
types/mousetrap/index.d.ts
vendored
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user