-
Notifications
You must be signed in to change notification settings - Fork 0
/
ko-co.d.ts
56 lines (51 loc) · 1.56 KB
/
ko-co.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* Options that define how a Konami Code sequence is detected.
*/
export interface KonamiCodeDetectionOptions
{
/**
* Determines whether the enter key is required to conclude a Konami Code sequence.
*/
requireEnterPress? : boolean;
/**
* The maximum amount of time (in milliseconds) to wait between key presses before sequence progress is reset.
*/
allowedTimeBetweenKeys? : number;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/**
* A synchronous function that will remove support for the Konami Code.
*/
export interface KonamiCodeSupportRemover
{
() : void
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/**
* Adds support for the Konami Code.
*
* Example usage:
*
* ``` js
* koco.addSupportForTheKonamiCode(
* {
* allowedTimeBetweenKeys : 500
* });
* ```
*
* Once support is added, all elements will now fire a `konamicode` event whenever the user enters the Konami Code sequence:
*
* ``` js
* target.addEventListener('konamicode', () =>
* {
* console.log('The Konami Code has been entered. 30 more lives for you!');
* });
* ```
*
* **Note:** The `konamicode` event bubbles and is cancelable.
*
* @param options Options that define how a Konami Code sequence is detected. By default, the enter key is not required to conclude the Konami Code sequence and it will wait indefinitely between key presses.
*
* @returns A synchronous function that can be called to remove support for the Konami Code.
*/
export function addSupportForTheKonamiCode(options? : KonamiCodeDetectionOptions) : KonamiCodeSupportRemover;