[](https://www.npmjs.com/package/@uiwwsw/easter-egg) [](https://github.com/uiwwsw/easter-egg/actions
npm install @uiwwsw/easter-egg



A simple JavaScript/TypeScript library to add an easter egg (Konami Code) to your web applications.
- Detects custom keyboard and pointer event sequences (default: Konami Code).
- Executes a callback function upon successful sequence entry.
- Basic debugger detection and code obfuscation for fun.
To use this library in your project, you can install it via Bun:
``bash`
bun add @uiwwsw/easter-eggOr if you're using npm/yarn
npm install @uiwwsw/easter-egg
yarn add @uiwwsw/easter-egg
`typescript
import { createEasterEgg } from '@uiwwsw/easter-egg';
createEasterEgg(
document.body, // The element to listen for keyboard/pointer events
() => {
alert('Easter Egg Triggered!');
// Your custom easter egg logic here
},
[
'keyboard:ArrowUp',
'keyboard:ArrowUp',
'keyboard:ArrowDown',
'keyboard:ArrowDown',
'keyboard:ArrowLeft',
'keyboard:ArrowRight',
'keyboard:ArrowLeft',
'keyboard:ArrowRight',
'keyboard:b',
'keyboard:a',
] // Konami Code
);
`
Each entry in the array follows the format :
- keyboard: listens for keyboard events fired on keydown.pointer:
- listens for pointer/mouse interactions such as click, pointerdown, or dblclick.
Need mouse interactions too? Mix and match both types:
`typescript`
createEasterEgg(document.body, () => {
console.log('Keyboard and pointer combo unlocked!');
}, [
'keyboard:Shift',
'pointer:click',
'pointer:click',
'keyboard:Enter',
]);
As demonstrated in index.html:
`html`
To run the demo page (index.html), you can use a simple static file server. If you have Bun installed, you can use bun --watch server.ts (as defined in package.json's dev script) or any other static server.
`bash`
bun run dev
Then open http://localhost:3000 in your browser.
To build the distributable files (.js and .d.ts) for the library:
`bash`
bun run build
This will output the compiled files into the dist/` directory.
This project is licensed under the MIT License. See the LICENSE file for details.