18 lines
595 B
TypeScript
18 lines
595 B
TypeScript
function onKonamiCode(callback: () => void): void {
|
|
let input = "";
|
|
const konami =
|
|
"arrowuparrowuparrowdownarrowdownarrowleftarrowrightarrowleftarrowrightba";
|
|
document.addEventListener("keydown", (e: KeyboardEvent) => {
|
|
input = (input + e.key.toLowerCase()).slice(-konami.length);
|
|
if (input === konami) callback();
|
|
});
|
|
}
|
|
|
|
onKonamiCode(() => {
|
|
document.body.classList.toggle("bg-black");
|
|
document.body.classList.toggle("bg-white");
|
|
const header = document.getElementById("header");
|
|
header?.classList.toggle("text-white");
|
|
header?.classList.toggle("text-black");
|
|
});
|