Skip to content

pheisiph/knami

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Knami - Konami Code for jQuery

A jQuery plugin to infuse your website with support for the Konami Code.

If a user keys in the Konami Code in the correct order, a callback function provided by you gets executed. If a mistake is made (another key pressed, the sequence broken), the sequence gets reset.

Include jQuery file and then invoke the plugin by passing it the callback that gets executed whenever the Konami Code has been entered. Like, so:

$(document).ready(function() {
    $.knami({
        onKonamiCodeComplete: function() {
            alert("Full health restored!");
        }
    });
});

You don't have to use the original Konami Code. You can define your own key sequence to trigger the callback by passing an array of Javascript Char keyCodes called konamiCode along with the options object.

There are also a few more callbacks that get called when the keys in the Konami Code are pressed:

$(document).ready(function() {
    $.knami({
        konamiCode: [38,13] // up, enter
        onKonamiCodeComplete: function() {
            alert("Full health restored!");
        },
        onKonamiKeyPress: function() {
            console.debug("I get called whenever a key of the Code is pressed, regardless of whether is was in sequence or not.")
        },
        onKonamiKeyPressSequence: function() {
            console.debug("I get called whenever a key of the Code is pressed *in sequence*").
        }
    });
});

About

Knami - Konami Code for jQuery

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published