npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@shgysk8zer0/konami

v1.1.1

Published

A simple JavaScript module for adding Konami Code Easter Eggs

Downloads

142

Readme

Konami Code JS module

CodeQL Node CI Lint Code Base

GitHub license GitHub last commit GitHub release GitHub Sponsors

npm node-current npm bundle size gzipped npm

GitHub followers GitHub forks GitHub stars Twitter Follow

Donate using Liberapay

The Konami Code (Japanese: コナミコマンド, Konami Komando, "Konami command"), also commonly referred to as the Contra Code and sometimes the 30 Lives code, is a cheat code that appears in many Konami video games, as well as some non-Konami games. In the original code, the player has to press the following sequence of buttons on the game controller to enable a cheat or other effects:

↑ ↑ ↓ ↓ ← → ← → B A; sometimes Start and/or Select is added to the sequence (usually to start Single player or, Two player modes). ~Konami Code | Wikipedia

Quick Links

About

konami.js enables developers to easily add the Konami Code to their websites. Like other JavaScript solutions, this one adds keyboard listeners and waits for the specifc sequence of keys to be pressed. Unlike other solutions, however, this one:

  • Is a JavaScript module that may be imported
  • Returns a Promise that resolves when the correct sequence is entered and may be awaited
  • Supports AbortSignal
  • Allows specifying the EventTarget via the optional { target }.

Installation

npm

npm i @shgysk8zer0/konami

Git Submodule

git submodule add https://github.com/shgysk8zer0/konami.git js/konami

CDN (unpkg)

const { konami } = await import('https://unpkg.com/@shgysk8zer0/konami');

Updating

Git Submodule

git submodule update --remote -- js/konami

Tip: Use Dependabot to automatically get Pull Requests when a submodule or package is updated.

Options

import { konami } from '/js/konami/konami.js';

await konami({ target, delay, signal, capture });

| Name | Type | Default Value | Description | ------------|---------------|---------------|----------------------------------------- | target | EventTarget | globalThis | Target to listen for input on | | delay | Number | 1000 | Allowed delay in ms between inputs | | signal | AbortSignal | undefined | See signal on MDN | | capture | Boolean | true | See capture on MDN |

Example

From Submodule

import { konami } from '/js/konami/konami.js';

konami().then(/* Enter Cheat Mode! */);

From npm


import { konami } from '@shgysk8zer0/konami';
// or const { konami } = require('@shgysk8zer0/konami');

konami().then(/* Enter Cheat Mode! */);

Advanced

From unpkg CDN

const controller = new AbortController();
// This will use version 1.0.5
const { konami } = await import('https://unpkg.com/@shgysk8zer0/[email protected]/konami.js');

try {
  await konami({
    delay: 500,
    target: document.getElementById('konami-target'),
    signal: controller.signal,
    capture: true,
  });

  /* Enter Cheat Mode! */
} catch(err) {
  // Signal was aborted
}

Requirements

Due to use of signal, support is currently limited to browsers supporting AbortSignal & AbortController. Support may be extended to other browser by importing a polyfill.

Supported Browsers

| Browser | Supported | Version | Released | --------------------|-----------|---------|------------ | Internet Explorer | 𐄂 | | | | Edge | ✓ | 16 | 2017-10-16 | | Safari | ✓ | 12.1 | 2019-03-24 | | Chrome | ✓ | 66 | 2018-04-16 | | Firefox | ✓ | 57 | 2017-11-13 | | Node | ✓ | 15 | ? | | Deno | ✓ | 1.0 | ? |