
Product
A Fresh Look for the Socket Dashboard
We’ve redesigned the Socket dashboard with simpler navigation, less visual clutter, and a cleaner UI that highlights what really matters.
react-konami-code
Advanced tools
Trigger an easter egg by pressing a sequence of keys. Available as a component or a custom hook. Supports timeout and input debounce/reset.
Trigger an easter egg by pressing a sequence of keys. Also available as a custom hook.
npm i react-konami-code -S
Clone this repo and run npm start
in the example
folder.
import React from 'react';
import Konami from 'react-konami-code';
export default class App extends React.Component {
easterEgg = () => {
alert('Hey, you typed the Konami Code!');
}
render = () => (
<Konami action={this.easterEgg}>
{"Hey, I'm an Easter Egg! Look at me!"}
</Konami>
)
}
import * as React from 'react';
import Konami from 'react-konami-code';
export default class App extends React.Component {
public render = () => (
<Konami action={this.easterEgg}>
{"Hey, I'm an Easter Egg! Look at me!"}
</Konami>
)
private easterEgg = () => {
alert('Hey, you typed the Konami Code!');
}
}
Refer to the Using the custom Hook section.
The content to be displayed should be passed as children
inside the Konami
component, and it will be wrapped inside a div. You can however not pass any children, and then just use the action
callback to fire your easter egg.
You can pass children
and action
at the same time to display some content and fire a secondary action.
function
Default: null
The callback action that should fire when the code
is input.
string
Default: ""
CSS classes can be applied to the div wrapping your secret content. By default the div will always have the konami
className.
<Konami className="myclass">
{"Hey, I'm an Easter Egg!"}
</Konami>
will result in:
<div className="konami myclass">
Hey, I'm an Easter Egg!
</div>
Array<number>
Default: [38,38,40,40,37,39,37,39,66,65]
An array with the sequence of keyCodes necessary to trigger the action
. The default code is the Konami Code: ↑ ↑ ↓ ↓ ← → ← → B A
You can find the keyCodes for each character here.
boolean
Default: false
If the trigger should be disabled or not. This is dynamic and you can enable/disable at will. The action
callback will only trigger when disabled == false
.
function
The callback to fire when the timeout
is finished, if any.
number
Default: 1000
The delay interval on which you need to start the input again. If you set it to 0
it will never reset the user input. Value should be in ms.
number
Default: null
The timeout to hide the easter egg. When the timeout is finished it will set display: none
to the wrapping div and will fire onTimeout
. By default it runs forever. Value should be in ms.
If you want to call an action without rendering children or handling timeouts it's recommended to use the useKonami
hook.
import React from 'react';
import { useKonami } from 'react-konami-code';
const easterEgg = () => {
alert('Hey, you typed the Konami Code!');
}
export default () => {
useKonami(easterEgg);
return <div />;
};
useKonami(action, [options])
function
Required
The callback action that should fire when the code
is input.
object
code
Default: [38,38,40,40,37,39,37,39,66,65]
An array with the sequence of keyCodes necessary to trigger the action
. Refer to main code
section for the keyCodes.
You can reach me on my Github or send an email to dev@vmarches.in.
2.3.0
Package updates and fixes
FAQs
Trigger an easter egg by pressing a sequence of keys. Available as a component or a custom hook. Supports timeout and input debounce/reset.
The npm package react-konami-code receives a total of 3,969 weekly downloads. As such, react-konami-code popularity was classified as popular.
We found that react-konami-code demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We’ve redesigned the Socket dashboard with simpler navigation, less visual clutter, and a cleaner UI that highlights what really matters.
Industry Insights
Terry O’Daniel, Head of Security at Amplitude, shares insights on building high-impact security teams, aligning with engineering, and why AI gives defenders a fighting chance.
Security News
MCP spec updated with structured tool output, stronger OAuth 2.1 security, resource indicators, and protocol cleanups for safer, more reliable AI workflows.