code-easter-eggs
v1.0.1
Published
Add hidden easter eggs and cheat codes to your website easily ๐ฅ
Maintainers
Readme
๐ฅ code-easter-eggs (eggify)
Add hidden easter eggs and cheat codes to your website with one line.
npm install code-easter-eggsFeatures
- Lightweight (~1-2 KB gzipped)
- Browser-only (requires DOM and KeyboardEvent API)
- Custom cheat code patterns
- Optional key delay limit
- Works with AbortController
- Ignores input/textarea by default
- Works with modern bundlers (Webpack, Vite, etc.)
Platform Support
- โ Browsers (Chrome, Firefox, Safari, Edge)
- โ Electron apps
- โ Browser extensions
- โ Node.js (server-side)
- โ React Native
- โ Terminal applications
How to use it
ESM (Browser/Bundler)
import { onCheatCode } from "code-easter-eggs";
onCheatCode("โโโโโโโโBA", () => {
alert("๐ฅ Secret unlocked!");
});CJS (Bundler with CommonJS)
const { onCheatCode } = require("code-easter-eggs");
// Note: Still requires browser environment
onCheatCode("โโโโโโโโBA", () => {
console.log("hi!");
});Browser (UMD/IIFE)
<script src="https://unpkg.com/code-easter-eggs/dist/index.global.js"></script>
<script>
Eggify.onCheatCode("โโโโโโโโBA", () => alert("๐ฅ"));
window.onCheatCode("โโโโโโโโBA", () => alert("๐ฅ (shim)"));
</script>Global
import "code-easter-eggs";
window.onCheatCode!("โโโโโโโโBA", () => { /* ... */ });
Different ways to introduce codes
Secret code
onCheatCode("โโโโโโโโBA", () => {
alert("๐ฅ Secret unlocked!");
});Key code
onCheatCode('ArrowUp ArrowUp ArrowDown ArrowDown ArrowLeft ArrowRight ArrowLeft ArrowRight b a', () => {
showEasterEgg('FAMOUS CODE!<br/>30 Lives Unlocked! ๐ฎ', '๐น๏ธ');
});
// Secret code --> dev mode
onCheatCode('KeyD keyE keyV Space KeyM KeyO KeyD KeyE', () => {
showEasterEgg('Developer Mode ON<br/>Console access granted! ๐จโ๐ป', '๐ป');
});Simple word cheat code
onCheatCode('eggify', () => {
showEasterEgg('You found the Eggify secret! ๐ฅโจ', '๐ฅ');
});Number sequence
onCheatCode('1 2 3 4 5', () => {
showEasterEgg('Numbers are magic! ๐ขโจ', '๐ข');
});
Collaborate
# build
npm run build
# create local package
npm pack
# test in other project
mkdir ../eggify-test && cd ../eggify-test
npm init -y
npm install ../ruta/a/eggify-1.0.0.tgz
# link to dev
npm link
# in eggify-test/
npm link eggify
# serve html example
npx http-server ./local-browser-test -p 4000
# open http://localhost:4000Size check
npm install -g gzip-size-cli
gzip-size dist/index.js dist/index.cjs dist/index.global.js
1.26 kB
๐ง AI Usage Notice
AI was used as a tool for assistance โ for example, to write comments, extract certain types, or configure some options.
However, this is NOT an AI-driven coding project.
If you wish to contribute code that involves AI assistance, please add a comment at the end of the file stating:
// Contains AI-generated codeso it can be reviewed in more detail.
(Fragment created using AI)
I will add custom instructions for copilot in the near future
License
Beerware ๐บ โ do whatever you want with it, but if we meet, buy me a beer. (This is essentially MIT-like. Use it freely, but if we meet, buy me a beer)
