Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Type definitions #30

Merged
merged 1 commit into from
Jun 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Type definitions for hotkeys v3.3.3
// Project: https://github.com/jaywcjlove/hotkeys
// Definitions by: Eager Wei <https://github.com/weidapao>

interface HotkeysEvent {
key: string
method: KeyHandler
mods: number[]
scope: string
shortcut: string
}

interface KeyHandler {
(keyboardEvent: KeyboardEvent, hotkeysEvent: HotkeysEvent): void
}

interface FilterEvent {
target?: {
tagName?: string
}
srcElement?: {
tagName?: string
}
}

interface Hotkeys {
(key: string, callback: KeyHandler): void
(key: string, scope: string, callback: KeyHandler): void

shift: boolean
ctrl: boolean
alt: boolean
option: boolean
control: boolean
cmd: 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
isPressed(keyCode: string): boolean
getPressedKeyCodes(): number[]

filter(event: FilterEvent): boolean
}

declare var hotkeys: Hotkeys

declare module 'hotkeys' {
export = hotkeys
}