All Projects → wKovacs64 → use-secret-code

wKovacs64 / use-secret-code

Licence: MIT license
Custom hook for adding cheat codes to your React app.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to use-secret-code

state-machine-demo
A React state machine demo using xstate
Stars: ✭ 18 (+12.5%)
Mutual labels:  state-machine, xstate
annihilate
js action game
Stars: ✭ 49 (+206.25%)
Mutual labels:  state-machine, xstate
simple-state-machine
A simple Java state machine for Spring Boot projects
Stars: ✭ 25 (+56.25%)
Mutual labels:  state-machine, statechart
ember-statechart-component
Statecharts as components. No classes. Pure declarative state transitions.
Stars: ✭ 28 (+75%)
Mutual labels:  statechart, xstate
react-gizmo
🦎 React Gizmo - UI Finite State Machine for React
Stars: ✭ 39 (+143.75%)
Mutual labels:  state-machine, xstate
xstate
State machines and statecharts for the modern web.
Stars: ✭ 21,286 (+132937.5%)
Mutual labels:  state-machine, statechart
xstate-viz
Visualizer for XState machines
Stars: ✭ 274 (+1612.5%)
Mutual labels:  state-machine, xstate
statechart
A rust implementation of statecharts: hierarchical, reactive state machines
Stars: ✭ 41 (+156.25%)
Mutual labels:  state-machine, statechart
qm
QM model-based design tool and code generator based on UML state machines
Stars: ✭ 54 (+237.5%)
Mutual labels:  state-machine, statechart
xstate-cpp-generator
C++ State Machine generator for Xstate
Stars: ✭ 33 (+106.25%)
Mutual labels:  state-machine, xstate
qp-arduino
QP real-time embedded frameworks/RTOS for Arduino (AVR and SAM)
Stars: ✭ 37 (+131.25%)
Mutual labels:  state-machine, statechart
xstate-react-router
XState connector to React Router.
Stars: ✭ 23 (+43.75%)
Mutual labels:  state-machine, xstate
ThingML
The ThingML modelling language
Stars: ✭ 91 (+468.75%)
Mutual labels:  state-machine, statechart
use-state-machine
Use Finite State Machines with React Hooks
Stars: ✭ 28 (+75%)
Mutual labels:  state-machine, react-hooks
xstate-catalogue
Professionally designed, interactive state machines
Stars: ✭ 616 (+3750%)
Mutual labels:  state-machine, xstate
Xstate
State machines and statecharts for the modern web.
Stars: ✭ 18,300 (+114275%)
Mutual labels:  state-machine, statechart
StateBuilder
State machine code generator for C++ and Java.
Stars: ✭ 30 (+87.5%)
Mutual labels:  state-machine, statechart
flow
A Statically Type Checked State Machine DSL for Kotlin
Stars: ✭ 74 (+362.5%)
Mutual labels:  state-machine
add-my-name
No more WhatsApp spams 🎉
Stars: ✭ 16 (+0%)
Mutual labels:  react-hooks
veact
Mutable state enhancer library for React based on @vuejs
Stars: ✭ 62 (+287.5%)
Mutual labels:  react-hooks

use-secret-code

Custom hook for adding cheat codes to your React app.

npm Version Build Status Code Coverage

Installation

npm install use-secret-code

What is this?

This is a custom React hook for adding "cheat codes" to your app. It will listen for a given sequence of keystrokes and track whether the corresponding "cheat" is enabled or disabled. You can then react (😏) accordingly (e.g. toggle a feature, pop an alert or notification, etc.). Just having a little fun here with this throwback to how we used to enter cheat codes in video games.

Package Name

This package was originally called use-cheat-code but apparently the word "cheat" is against npm policies, so they denied my attempt to publish the package under that name and I was forced to pick a new name. I went with use-secret-code (it's not great, but what else do you call a cheat code?), but I still export useCheatCode as well as useSecretCode. They are the same thing, but I will personally be importing useCheatCode in my own projects.

Usage

// import { useSecretCode } from 'use-secret-code'; // alternate
import { useCheatCode } from 'use-secret-code';

function CheatCodeExample() {
  const invulnerability = useCheatCode(['i', 'd', 'd', 'q', 'd']);
  return (
    <span>Invulnerability: {invulnerability ? 'enabled' : 'disabled'}</span>
  );
}

Browser Support

This should work in all modern browsers, but you'll need to polyfill Set for use in IE11. See the playground project in the example directory for one approach.

License

This module is distributed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].