Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Konami.js is an ES6 JavaScript instance that allows web developers to implement the Konami code on their web pages. By pressing up, up, down, down, left, right, left, right, B, A, Enter, one or more custom JavaScript functions will execute.

License

CharlesStover/konami-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Konami.js Tweet

Konami.js is a JavaScript package that allows web developers to implement an event listener for the Konami code on their web pages. By pressing up, up, down, down, left, right, left, right, B, A, Enter, one or more custom JavaScript functions will execute.

package minified size minzipped size downloads build

Examples

ES6

Install

  • npm install @gamingmedley/konami.js --save or
  • yarn add @gamingmedley/konami.js

Adding an Event Listener

import Konami from '@gamingmedley/konami.js';
Konami.add(() => {
  alert('This will alert every time the Konami code is entered.');
});

Adding a Single-Execution Event Listener

import Konami from '@gamingmedley/konami.js';
Konami.add((unsubscribe) => {
  unsubscribe(); // Unsubscribes the listener from future Konami code entries.
  alert('This will only alert the first time the Konami code is entered.');
});

Removing an Event Listener

import Konami from '@gamingmedley/konami.js';
const unsubscribe = Konami.add(() => {
  alert('This will not alert, because it will have been removed.');
});
unsubscribe();

Methods

add

Queues a function to be executed when the Konami code is entered by the user.

Returns an unsubscribe function. When executed, the unsubscribe function will disable the associated function from executing in future uses of the Konami code.

Parameters

  • function e: The function to be executed when the Konami code is entered by the user. An unsubscribe function is passed as a parameter to it.

remove

The function associated with the ID will no longer execute when the Konami code is entered.

Returns true on success, false on failure.

Parameters

  • string id: The ID of the event to remove.

About

Konami.js is an ES6 JavaScript instance that allows web developers to implement the Konami code on their web pages. By pressing up, up, down, down, left, right, left, right, B, A, Enter, one or more custom JavaScript functions will execute.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published