Skip to content

Instantly share code, notes, and snippets.

@bradleypriest
Last active December 17, 2015 00:29
Show Gist options
  • Save bradleypriest/5521322 to your computer and use it in GitHub Desktop.
Save bradleypriest/5521322 to your computer and use it in GitHub Desktop.
Ember.KonamiCode
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