The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

Konami Code

Last updated on:
var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";

$(document).keydown(function(e) {

  kkeys.push( e.keyCode );

  if ( kkeys.toString().indexOf( konami ) >= 0 ) {

    // do something awesome



  1. Russ
    Permalink to comment#

    You misspelled Konami.



  2. Josh
    Permalink to comment#

    Such a good idea :D

  3. Johnny
    Permalink to comment#

    30 lives!

  4. Rowe
    Permalink to comment#

    Is this like an easter egg? … can the user just type the “code” anywhere / anytime the window is active? … if you have a minute, can you give a more fully formed example of a use case or some explanatory text on configuring this function. Thanks! Very cool.

    • Kim
      Permalink to comment#

      I’m not the author of this function, but this is probably just for easter egg fun given the nature of the “real” Konami code. The method is being called on the document, so yes, it should work “anywhere” as long as the window is active.

      As for use cases, just Google “Konami code” or see an article roundup like this one: for examples of this type of thing being used.

  5. Michael Beckwith
    Permalink to comment#

    I know this has floated around for awhile as I found it myself elsewhere on the internet. It’s not exactly efficient code. It tracks all keystrokes you make and if it’s on a site that you’re doing a lot of typing on, that could add up to a lot of js memory use. Granted most of the time, it’d probably be on a site that you’re just viewing.

    You can see my attempt to rewrite it, in a much more lightweight efficient way here:

  6. nicolas
    Permalink to comment#

    I couldn’t figure what is it?? What is this for?

Leave a Comment

Posting Code

We highly encourage you to post problematic HTML/CSS/JavaScript over on CodePen and include the link in your post. It's much easier to see, understand, and help with when you do that.

Markdown is supported, so you can write inline code like `<div>this</div>` or multiline blocks of code in in triple backtick fences like this:

  function example() {
    element.innerHTML = "<div>code</div>";

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed