Last active
December 17, 2015 00:29
-
-
Save bradleypriest/5521322 to your computer and use it in GitHub Desktop.
Ember.KonamiCode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ember.KonamiCode = Ember.Mixin.create({ | |
konami: [38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13], | |
currentIndex: 0, | |
keyPress: function(event) { | |
this._super(event); | |
var index = this.get('currentIndex'); | |
if (event.keyCode === this.konami[index]) { | |
if (index === 10) { | |
this.success(); | |
} else { | |
this.set('currentIndex', index + 1); | |
} | |
} else { | |
this.set('currentIndex', 0); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment