Skip to content

konami-emoji-blast

konami-emoji-blast is a package that combines two others:

  1. konami-code-js: detects when the user has entered the Konami Code…
  2. emoji-blast: …to start emojiBlast()s until the code is entered again.

If a user presses up up down down left right left right b a on their keyboard or taps it on their mobile phone, emoji blasts will start firing on the page. Triggering the code again stops the blasts.

Getting Started

Dedicated integrations exist for adding konami-emoji-blast with common frameworks:

Otherwise, this page will get you started as quickly as possible.

Quick Bundler Start

If you’re writing JavaScript or TypeScript with a bundler, first install the konami-emoji-blast package as a dependency:

Terminal window
npm i konami-emoji-blast

You can then import it in your code to access its initializeKonamiEmojiBlast function:

import { initializeKonamiEmojiBlast } from "konami-emoji-blast";
initializeKonamiEmojiBlast();

Quick HTML Start

If you’re directly writing an .html document, plop this πŸ‘‡ at the end of your <body>:

<script async src="https://unpkg.com/konami-emoji-blast/dist/now.js"></script>

That πŸ‘† loads konami-emoji-blast soon after your page loads to set up the Konami Code with no configuration.

πŸ‘Œ.

You might want a little more fine-grained control over when the connection is created. Use this πŸ‘‡ alternate script to create a global initializeKonamiEmojiBlast function:

<script src="https://unpkg.com/konami-emoji-blast/dist/global.js"></script>
<script>
initializeKonamiEmojiBlast();
</script>

API

konami-emoji-blast export a single function:

initializeKonamiEmojiBlast

import { initializeKonamiEmojiBlast } from "konami-emoji-blast";
initializeKonamiEmojiBlast();

This will create a new konami-code-js KonamiCode instance to listen for user input. It will call emojiBlasts whenever the code is detected.

initializeKonamiEmojiBlast() returns a cancellation function that cancels any pending work.

// Commence code listening!...
const cancel = emojiBlasts();
// ...but not after ten seconds.
setTimeout(stop, 10000);

initializeKonamiEmojiBlast Options

initializeKonamiEmojiBlast may take a single optional parameter, onActivate.

onActivate

A function to run whenever the user inputs the Konami Code.

import { initializeKonamiEmojiBlast } from "konami-emoji-blast";
initializeKonamiEmojiBlast(() => {
console.log("Commence blasting! πŸŽ†");
});