a cheat code shooter with TypeScript, and also refer to it as 'konami code'
npm install cheatcode-shooterkonami code


English | 简体中文(Chinese) | 日本語(Japanese)
``bash`
pnpm add cheatcode-shooter
`typescriptcheat
// btw, it was initially named cheat-shooter, but npm disallowed the use of .
import { CheatShooter } from 'cheatcode-shooter';
const actions = {
'konami': () => {
// Your action for the Konami code
console.log('konami')
},
// Add more actions as needed
};
const cheatShooter = new CheatShooter(actions);
cheatShooter.on('command', (commandInfo: Output) => {
if (commandInfo) {
console.log(Command detected: ${commandInfo.input});
} else {
console.log('Invalid command');
}
});
// Access the available commands
console.log('Available commands:', cheatShooter.commands);
// Destroy the cheat shooter when it's no longer needed
cheatShooter.destroy();
`
`typescript`
interface Output {
step: number;
input: string;
guesses: string[];
}
new CheatShooter(actions: Record
> Creates a new CheatShooter instance with the specified actions.
destroy(): void
> Removes event listeners and cleans up resources when the CheatShooter is no longer needed.
on(event: EventType, callback: EventCallback): Function
> Registers a callback function to be called when a command is detected. Returns a function to remove the listener.
commands: string[]`
> An array of available cheat commands.
This project is licensed under the MIT License - see the LICENSE file for details