pour toi loulou2

This commit is contained in:
joniboy74prog
2023-12-08 05:31:52 +01:00
parent f234dbb239
commit ba13c45fe8
4 changed files with 88 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
const allowedKeys = {
37: 'left',
38: 'up',
39: 'right',
40: 'down',
65: 'a',
66: 'b',
};
const konamiCode = [
'up',
'up',
'down',
'down',
'left',
'right',
'left',
'right',
'b',
'a',
];
let konamiCodePosition = 0;
document.addEventListener('keydown', function(e) {
let key = allowedKeys[e.keyCode];
let requiredKey = konamiCode[konamiCodePosition];
if (key === requiredKey) {
konamiCodePosition++;
if (konamiCodePosition === konamiCode.length) {
activateCheats();
konamiCodePosition = 0;
}
} else konamiCodePosition = 0;
});
const activateCheats = () => {
alert('cheats activated');
// TODO redirect to easter egg page
};