georgemandis / konami-js

Adding the Konami Code easter egg to your projects since 2009! Compatible with gestures on smartphones and tablets as well. Compatible with all front-end frameworks and vanilla JavaScript
http://konamijs.mand.is/
MIT License
959 stars 122 forks source link

Add a new method to enable/disable the Konami code #33

Closed mably closed 7 years ago

mably commented 7 years ago

Could be really useful when integrated into a single page application (SPA).

You might want to enable the Konami code only on some screens or pages.

It could also be useful to be able to reset the current inputs.

georgemandis commented 7 years ago

Thanks for the suggestion! Do you have any thoughts on how that might look? Do you have any examples of integrating the current version of konami-js in a SPA?

mably commented 7 years ago

We used it on one of our app to switch from test to prod environment ;)

It was used globally, changed a value in local storage and then reloaded the app (window.reload).

The problem is that it was being triggered by normal users navigating thru our app, a bit annoying ;)

So it could be interesting to be able to enable/disable it by adding a simple enable(bool) method or eventually allow to reset the current Konami inputs when changing screen with a clearInput() method for example.

georgemandis commented 7 years ago

That's an interesting use case :). You're not the only company I've heard of using it that way! Though using it to switch from test to production sounds kind of scary. You're braver than me!

A feature like you're describing would be easy enough to add. But I wonder if it makes more sense to solve it within the context of the SPA itself, rather than add it as a feature to konami-js? There are a lot of factors to consider I know. What framework are you using, if I might ask?

mably commented 7 years ago

It's an Angular app. Actually we had to remove the Konami part once a few of our testers switched to dev env accidentally ;)

FBerthelot commented 7 years ago

You can check the #34 Pull Request ;)

mably commented 7 years ago

Excellent! Will give it a try :)

georgemandis commented 7 years ago

I've merged #34. Give it another shot sometime @mably. Thanks for the update @FBerthelot!

mably commented 7 years ago

I will, thanks 😄