Skip to content

Commit

Permalink
doc: Improved documentation, making clear the nomenclature of the nav…
Browse files Browse the repository at this point in the history
…igation and control keys used for eastereggs codes
  • Loading branch information
EGAMAGZ committed May 22, 2024
1 parent e75c9b1 commit fad905b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
44 changes: 43 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,52 @@
/**
* Type with the properties of an easter egg.
*
* @example
* A simple easter egg:
* ```typescript
* import { EasterEgg } from "@egamagz/paska-ovo";
*
* const easterEgg: EasterEgg = {
* code: ["up", "up", "down", "down", "left", "right", "left", "right", "b", "a"],
* onFound: () => {
* // Do something when the easter egg is found
* },
* tag: "Konami",
* }
* ```
*
* @example
* An easter egg with a duration:
* ```typescript
* const easterEgg: EasterEgg = {
* code: ["up", "right", "down", "left"],
* onFound: () => {
* // Do something when the easter egg is found
* },
* onFinish() {
* // Do something when the duration of the easter egg is over
* },
* duration: 1000,
* tag: "Barrel Roll"
* }
* ```
*/
export type EasterEgg = {
/**
* Sequence of keys that will trigger the easter egg.
* Key sequence that will activate the easter egg. The code can contain
* letters (which will only be detected as lowercase), numbers and navigation
* and control keys. The navigation and control keys are indicated by the following nomenclature:
* * `up`: `ArrowUp`
* * `down`: `ArrowDown`
* * `left`: `ArrowLeft`
* * `right`: `ArrowRight`
* * `enter`: `Enter`
* * `space`: `Space`
* * `ctrl`: `Control`
* * `alt`: `Alt`
* * `tab`: `Tab`
* * `esc`: `Escape`
* * `slash`: `/`
*/
code: string[],
/**
Expand Down
1 change: 0 additions & 1 deletion src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ export const SPECIAL_KEYS: Record<string, string> = {
"tab": "Tab",
"esc": "Escape",
} as const;

0 comments on commit fad905b

Please sign in to comment.