Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

cm/konamify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Konamify

A utility function for observing Konami code input in a web browser.

Installation:

npm install konamify

Or include the following script in your webpage:

<script src="https://unpkg.com/konamify/konamify.min.js"></script>

Or it may be easier to just add the required code to your project manually. Simply paste the following:

function konamify (cb) {
    var k = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13], i = 0;
    window.addEventListener('keydown', function (e) {
        i = (e.keyCode === k[i]) ? i + 1 : 0;
        if (i === k.length) cb();
    });
};

Example usage:

konamify(function () {
    console.log('Konami code successfully entered!')
})

How to: In order to activate the konami code enter the following in a browser.

UP UP DOWN DOWN LEFT RIGHT LEFT RIGHT B A ENTER