Class: CheatCode

CheatCode(name, code, callback)

new CheatCode(name, code, callback)

Parameters:
Name Type Description
name String | Object Identifier or settings object
code String | Array Code
callback function Callback function

Members

callback :function

Type:
  • function

code :Array.<number>|Array.<string>|String

The chain of keys to trigger the cheat
Type:
  • Array.<number> | Array.<string> | String

(readonly) enabled :boolean

Get enabled state.
Type:
  • boolean

timeout :Number

Duration before cheatcode timer resets
Type:
  • Number

Methods

(static) compile(v) → {Array.<number>}

Converts a cheatcode in any supported format into a number array
Parameters:
Name Type Description
v Array.<string> | string
Returns:
Type
Array.<number>

bind()

Bind the event listener

check(keys) → {boolean}

Compare keylist with cheat code and trigger the callback
Parameters:
Name Type Description
keys Array.<string>
Returns:
Type
boolean

disable()

Sets enabled to true, shorthand for CheatCode#toggle(false)

enable()

Sets enabled to true, shorthand for CheatCode#toggle(true)

reset()

Resets the current keys chain

toggle(conditionopt)

Toggle the enabled state of the cheatcode
Parameters:
Name Type Attributes Description
condition boolean <optional>
Force a toggle state

unbind()

Unbind the event listener