Giter VIP home page Giter VIP logo

konami-code's Introduction

Konami Code For jQuery

By Tom McFarlin. Last Updated 4 December 2015.

About

Using the Konami code, easily configure and Easter Egg for your page or any element on the page.

Parameters

  • code Personalized code.
  • cheat The callback function to fire once the cheat code has been entered.
  • eventName jQuery event name for default callback
  • eventProperties event property override for default callback

Installation

bower install konami-code

Instructions

Include the plugin in the header of your page:

	<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>`
	<script src="jquery.konami.js" type="text/javascript"></script>

With callback

Apply the plugin to a selector to capture keypresses:

  $( window ).konami();
  $( '.konami-sensitive' ).konami();

Specify a callback to fire once the code has been entered:

  $( window ).konami({
		cheat: function() {
			alert( 'Cheat code activated!' );
		}
	});

Using jQuery events

Catch the konami code with a jQuery event handler:

  $( window ).konami();
  $( window ).on('konami', function() {
    alert( 'Cheat code activated!' );
  })

Add extra data to the jQuery event callback:

  $( window ).konami( { message: 'special message' } );
  $( window ).on('konami', function(evt, extraParam) {
    alert( 'Cheat code activated: ' + extraParam.message + '!' );
  })

Use event names:

  $('.type1').konami( { eventName: 'konami.on.type1' } );
  $('.type2').konami( { eventName: 'konami.on.type2' } );
  $( window ).on('konami.on.type2', function(evt, extraParam) {
    alert( 'Cheat code activated on a type2 element' );
  })

Personallizing the code

You can personalize the code too, just entering a array with ASCII codes keys in code param

  $( window ).konami({
  		code : [38,38,40,40,37,39,37,39], // up up down down left right left right
		cheat: function() {
			alert( 'Cheat code activated!' );
		}
	});

Contact

License

MIT license

konami-code's People

Contributors

darylf avatar kkemple avatar paulmurraycbr avatar stephen-hill avatar tommcfarlin avatar weiland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

konami-code's Issues

Add 1.3.4 tag for bower

The most recent tag is 1.3.2, which actually has 1.3.0, and doesn't have events.

So, bower grabs that version, rather than the most recent version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.