I am trying to create a .js file for a website that, by entering the code with the keys Up, Up, Down, Down, Left, Right, Left, Right, B, A, Start (enter), will insert a video, However, when entering the correct The web page should display something like โkeep movingโ, if the wrong key is entered, it should display โincorrect, try againโ and allow them to start working.
I was able to process JavaScript when when I enter the correct code, it displays a warning, and entering the wrong code displays a different code.
I managed to get this code using online resources, but none of them explains how to make a mistake, try again a part
if (window.addEventListener) { var keys = [], konami = "38,38,40,40,37,39,37,39,66,65,13"; window.addEventListener("keydown", function(e){ keys.push(e.keyCode); if (keys.toString().indexOf(konami) >= 0) { alert('Right'); keys = []; }; if (keys.toString().indexOf(konami) < 0) { alert('Wrong'); keys = []; } }, true);
};
Any help would be greatly appreciated.