Skip to content

jQuery.easterEgg - feeling adventurous? Add a hidden treasure to your page!

License

Notifications You must be signed in to change notification settings

martinkr/jQuery.easterEgg

Repository files navigation

jQuery.easterEgg - feeling adventurous? Add a hidden treasure to your page!

Type the right key sequence right upon entering to unlock the hidden treasue. The plugin will start watching upon the first keypress - don't hesitate ;)

Features

  • Multiple easterEggs on one page: hide easter eggs on specific element
  • Use your own key sequence: with the konami code as the default
  • Listen to "jQuery.easterEgg" or override the complete callback with your own function
  • Memory friendly: removes all events / data afterwards

Examples

Basic example

Installing the easter egg on the document body: triggers in the key sequence is entered while the focus is on the body-element. Uses the default key sequence - the konami code ("up up down down left right left right b a") and listens for the easter egg event "jQuery.easterEgg" to activate the hidden function.

  $('body').easterEgg();
  $('body').on('jQuery.esterEgg',function(){alert('konami code')});

Using a custom key sequence

Pass an object containing your sequence as an array of keycodes

  $('body').easterEgg( { keys:[66,65] } );

overriding the complete function

Replace the complete callback with your own function.

  $.fn.easterEgg.found = function () {
    alert('custom')
  } ;

Multiple easter eggs

  // install the konami code on the first input element
  $('input').easterEgg();
  $('input').on('jQuery.esterEgg',function(event_){ event_.stopPropagation(); alert('input: konami code')});

  // and the custom key sequence on the body
  $('body').easterEgg({keys:[66,65]});
  $('body').on('jQuery.esterEgg',function(){alert('body: custom code')});

Requires

License

Dual licensed under the MIT and GPL licenses.

Copyright (c) 2011 Martin Krause (jquery.public.mkrause.info)

About

jQuery.easterEgg - feeling adventurous? Add a hidden treasure to your page!

Resources

License

Stars

Watchers

Forks

Packages

No packages published