Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
function(spModal) {
var c = this;
console.log('Lol what are you doing here?');

const KONAMI_CODE = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown',
'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a'];
let inputSequence = [];
let timeoutId;

const handleKeyPress = (e) => {
// Clear timeout to reset sequence if user pauses too long
clearTimeout(timeoutId);

// Add key to sequence
inputSequence.push(e.key);

// Keep only the last N keys (length of Konami code)
if (inputSequence.length > KONAMI_CODE.length) {
inputSequence.shift();
}

// Check if current sequence matches Konami code
if (inputSequence.join(',') === KONAMI_CODE.join(',')) {
activateCheats();
inputSequence = []; // Reset after activation
}

// Reset sequence after 2 seconds of inactivity
timeoutId = setTimeout(() => {
inputSequence = [];
}, 2000);
};

const activateCheats = () => {
spModal.open({
size: 'sm',
title: 'Cheats activated',
message: 'Konami code entered',
buttons: [{ label: '${Close}', cancel: true }]
});
};

document.addEventListener('keydown', handleKeyPress);

// Cleanup listener when widget is destroyed
c.$onDestroy = function() {
document.removeEventListener('keydown', handleKeyPress);
clearTimeout(timeoutId);
};
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Konami Code Easter Egg

Put this code in the client controller of a widget to listen for the Konami Code. By default it just opens a modal notifying the user that the konami code as activated. Modify to do whatever fun things you want.

## Version 2

[KonamiCodeEasterEggV2.js]("Modern Development\Service Portal Widgets\Konami Code Easter Egg\KonamiCodeEasterEggV2.js") is the same code but improved with:

1. Uses e.key instead of e.keyCode (which is deprecated) with modern arrow key names
2. Automatically tracks only the last N keypresses instead of manual position tracking
3. Resets the sequence if the user pauses too long (more forgiving UX)
4. Removes event listener when widget is destroyed to prevent memory leaks
5. Uses array join comparison instead of position tracking
6. Modern variable declarations for better scoping

<img width="314" height="205" alt="image" src="https://github.com/user-attachments/assets/ea39dbdf-c252-4f7f-942d-8f26319ca6e2" />
Loading