@cjsase/cheatcode-js
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

cheatcode-js

This library provides a simple interface for checking cheat codes in keyboard inputs.

Usage

JavaScript

const cheatCode = new CheatCode()

document.addEventListener('keyup', event => {
  if (cheatCode.checkKeyboardEvent(event)) {
    alert('cheater');
  }
}

Angular

cheatCode = new CheatCode();

@HostListener('document:keyup', ['$event'])
onKeyup(event: KeyboardEvent) {
  if (this.cheatcode.checkKeyboardEvent(event)) {
    alert('cheater');
  }
}

Configuration

The CheatCode constructor takes 2 optional parameters. The first is an array of strings which represent a cheat code. The second is a configuration object. The only configuration option at this time is requireModifier which can be a string for a modifier key, if the cheatcode should only trigger when the modifier key is pressed while entering the combination

Readme

Keywords

none

Package Sidebar

Install

npm i @cjsase/cheatcode-js

Weekly Downloads

1

Version

0.0.5

License

MIT

Unpacked Size

4.62 kB

Total Files

6

Last publish

Collaborators

  • cjsase