simple key pattern manager to trigger custom events. typically used to set up easter eggs in a js app
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src
test
README.md
component.json
package.json

README.md

jsegg

jsegg is a small jQuery plugin designed to capture sequences of keys typed. A callback function is called when a full sequence is matched. It is typically use to trigger easter eggs, or keyboard controls.

eggs are attached to dom nodes and therefore capture bubbling events, giving you the ability to have the same keyboard sequence do different things, depending on what's focused when the user types.

Features

  • eggs are attached to DOM nodes, including document
  • multiple eggs can be attached to the same node

Usage

jsegg is used as any jQuery plugin: by being called on a jQuery object. The initialization call requires 2 arguments:

  • the keyboard sequence to capture
  • the callback function to execute on match

the keyboard sequence is defined either as:

Examples

$(document).jsegg('boo', function()
{
    console.log('got ya!')
});

jsegg contains 2 popular easter egg sequences, which can be accessed as such:

$(document).jsegg($.jsegg.KONAMI, function()
{
    console.log('Konami code!')
});
$(document).jsegg($.jsegg.SFII, function()
{
    console.log('SNES Street Fighter II code!')
});