mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
added Type definitions for keymaster v1.6.2,
Project: https://github.com/madrobby/keymaster
This commit is contained in:
@@ -190,6 +190,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [jsTree](http://www.jstree.com/) (by [Adam Pluciński](https://github.com/adaskothebeast))
|
||||
* [JWPlayer](http://developer.longtailvideo.com/trac/) (by [Martin Duparc](https://github.com/martinduparc/))
|
||||
* [KeyboardJS](https://github.com/RobertWHurst/KeyboardJS) (by [Vincent Bortone](https://github.com/vbortone/))
|
||||
* [keymaster.js](https://github.com/madrobby/keymaster) (by [Marting W. Kirst](https://github.com/nitram509/))
|
||||
* [KineticJS](http://kineticjs.com/) (by [Basarat Ali Syed](https://github.com/basarat))
|
||||
* [Knockback](http://kmalakoff.github.com/knockback/) (by [Marcel Binot](https://github.com/docgit))
|
||||
* [Knockout.js](http://knockoutjs.com/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path="keymaster.d.ts" />
|
||||
|
||||
// simple key binding without scope
|
||||
key('shift+a', function (keyboardEvent: KeyboardEvent, keymasterEvent: KeymasterEvent) {
|
||||
});
|
||||
|
||||
// simple key binding with scope
|
||||
key('shift+b', 'aScope', (keyboardEvent, keymasterEvent) => {
|
||||
});
|
||||
|
||||
// possible combinations of filtering
|
||||
key.filter({target: { tagName: 'propertytest'}});
|
||||
key.filter({srcElement: { tagName: 'propertytest'}});
|
||||
|
||||
Vendored
+60
@@ -0,0 +1,60 @@
|
||||
// Type definitions for keymaster v1.6.2
|
||||
// Project: https://github.com/madrobby/keymaster
|
||||
// Definitions by: Martin W. Kirst <https://github.com/nitram509>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.
|
||||
|
||||
interface KeymasterEvent {
|
||||
key: string;
|
||||
method: KeyHandler;
|
||||
mods: number[];
|
||||
scope: string;
|
||||
shortcut: string;
|
||||
}
|
||||
|
||||
interface KeyHandler {
|
||||
(keyboardEvent: KeyboardEvent, keymasterEvent: KeymasterEvent) : void;
|
||||
}
|
||||
|
||||
interface FilterEvent {
|
||||
target?: {
|
||||
tagName?: string;
|
||||
}
|
||||
srcElement?: {
|
||||
tagName?: string;
|
||||
}
|
||||
}
|
||||
|
||||
interface Keymaster {
|
||||
|
||||
(key: string, callback: KeyHandler): void;
|
||||
(key: string, scope: string, callback: KeyHandler): void;
|
||||
|
||||
shift: boolean;
|
||||
alt: boolean;
|
||||
option: boolean;
|
||||
ctrl: boolean;
|
||||
control: boolean;
|
||||
command: boolean;
|
||||
|
||||
setScope(scopeName: string): void;
|
||||
getScope():string;
|
||||
deleteScope(scopeName: string): void;
|
||||
|
||||
noConflict(): void;
|
||||
|
||||
unbind(key: string): void;
|
||||
unbind(key: string, scopeName: string): void;
|
||||
|
||||
isPressed(keyCode: number): boolean;
|
||||
getPressedKeyCodes(): number[];
|
||||
|
||||
filter(event: FilterEvent): void;
|
||||
}
|
||||
|
||||
declare var key: Keymaster;
|
||||
|
||||
declare module "keymaster" {
|
||||
export = key;
|
||||
}
|
||||
Reference in New Issue
Block a user