cheatz

0.1.1 • Public • Published

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

How to

npm install cheatz

then either use the dist/ files as cjs or the src files in type="module" like so:

<script type="module">
        import 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:

<script src="https://cheatz.surge.sh/cheatz.js"></script>
<script src="https://cheatz.surge.sh/keyecho.js"></script>

Then you can set the Cheat Codes like so: Cheatz

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().

constructor(mountPoint, sequence, callback, additionalMap = {})

the default ones are those, I am using the event.key value, defined in here.

const keyMaps = {
    "UP": "ArrowUp",
    "DOWN": "ArrowDown",
    "LEFT": "ArrowLeft",
    "RIGHT": "ArrowRight",
    "ENTER": "Enter",
    "TAB": "Tab",
    "CTRL": "Control",
    "ALT": "Alt",
    "SUPER": "Meta"
};

Keyecho

        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.

Package Sidebar

Install

npm i cheatz

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

9.95 kB

Total Files

7

Last publish

Collaborators

  • vikkio88