From 53847ce07db8bc7601fe3e10ffb1565c2531be2c Mon Sep 17 00:00:00 2001 From: Patrick Lee Date: Tue, 19 Dec 2017 15:47:30 +1100 Subject: [PATCH] Add Mousetrap.addKeycodes from 1.6 --- types/mousetrap/index.d.ts | 3 ++- types/mousetrap/test/index.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/types/mousetrap/index.d.ts b/types/mousetrap/index.d.ts index afd0f42cf7..b7e245f5e5 100644 --- a/types/mousetrap/index.d.ts +++ b/types/mousetrap/index.d.ts @@ -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 // 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; diff --git a/types/mousetrap/test/index.ts b/types/mousetrap/test/index.ts index 0ae40ea622..fae472b76f 100644 --- a/types/mousetrap/test/index.ts +++ b/types/mousetrap/test/index.ts @@ -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