Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vikkio88/cheatz
a small js library to hide easter eggs on your website
https://github.com/vikkio88/cheatz
cheatcodes easter-egg konamicode vanilla-js web
Last synced: 22 days ago
JSON representation
a small js library to hide easter eggs on your website
- Host: GitHub
- URL: https://github.com/vikkio88/cheatz
- Owner: vikkio88
- License: mit
- Created: 2024-02-05T21:08:34.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-02-07T21:00:41.000Z (9 months ago)
- Last Synced: 2024-10-11T23:50:18.841Z (25 days ago)
- Topics: cheatcodes, easter-egg, konamicode, vanilla-js, web
- Language: HTML
- Homepage: https://cheatz.surge.sh
- Size: 14.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cheatz
a small and dependecy free js library to hide easter eggs on your website.
You can use it to hide secret cheatcodes and it also includes a small utility to echo keys.[Example Website](https://cheatz.surge.sh/)
## How to
```
npm install cheatz
```then either use the `dist/` files as `cjs` or the `src` files in `type="module"` like so:
```htmlimport Cheatz from './Cheatz.js';
import Keyecho from './Keyecho.js';let keyEcho = null;
addEventListener("DOMContentLoaded", () => {
keyEcho = new Keyecho("body");new Cheatz("body", "i d d q d", function () {
```alternatively you can use the statically hosted lib on surge including it like so:
```html
<script src="https://cheatz.surge.sh/cheatz.js">```
Then you can set the Cheat Codes like so:
**Cheatz**
```js
addEventListener("DOMContentLoaded", () => {
// Konami code
new Cheatz("body", "UP UP DOWN DOWN LEFT RIGHT LEFT RIGHT A B", function () { /* DO SOMETHING */});
});```
You can customise also other key codes passing it as 4th parameter of `new Cheatz()`.
```js
constructor(mountPoint, sequence, callback, additionalMap = {})
```the default ones are those, I am using the `event.key` value, defined in [here](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values).
```js
const keyMaps = {
"UP": "ArrowUp",
"DOWN": "ArrowDown",
"LEFT": "ArrowLeft",
"RIGHT": "ArrowRight",
"ENTER": "Enter",
"TAB": "Tab",
"CTRL": "Control",
"ALT": "Alt",
"SUPER": "Meta"
};
```**Keyecho**
```js
let keyEcho = null;
addEventListener("DOMContentLoaded", () => {
keyEcho = new Keyecho("body");
});
```This will listen to every key press and echo them at the bottom right of the page.