I want to implement the Konami code on my webpage. I came across this easy-to-use javascript:
<script type="text/javascript">
if ( window.addEventListener ) {
var state = 0, konami = [38,38,40,40,37,39,37,39,66,65];
window.addEventListener("keydown", function(e) {
if ( e.keyCode == konami[state] ) state++;
else state = 0;
if ( state == 10 )
window.location = "http://www.konami.com/";
}, true);
}
</script>
However, on my webpage I want to have to have two different inputs that lead to two different websites. For example: if someone enters the [38,38,40,40,37,39,37,39,66,65] Konami sequence on their keyboard, then I want them to be redirected to “http://www.konami.com/“. But if someone enters google on their keyboard (i.e. 71,79,79,71,76,69) instead, then I want them to be redirected to “http://www.google.com/“.
Can someone please tell me how I can achieve this by altering the javascript above?
Try this: