Options
All
  • Public
  • Public/Protected
  • All
Menu

@twocatmoon/react-use-konami-code

Index

Type aliases

UseKonamiCodeOptions: { requireReturn?: boolean; sequence?: string[] }

Type declaration

  • Optional requireReturn?: boolean

    If true, a sequence must be followed by the return/enter key before activating

  • Optional sequence?: string[]

    Sequence of key strokes required to activate the callback

Functions

  • Calls a function when a sequence of key presses is detected.

    example
    export default function () {
    const [ state, setState ] = useState('foo')

    const options = {
    sequence: [ 'x', 'y', 'a', 'b' ],
    requireReturn: true
    }
    useKonamiCode(() => setState('bar'), options)

    return (<div>{state}</div>)
    })

    Parameters

    • callbackFn: () => void

      Function to be called when a sequence is detected

        • (): void
        • Returns void

    • Optional options: UseKonamiCodeOptions

    Returns void

Generated using TypeDoc