1.0.0 • Published 4 years ago

ng-konami v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

ng-konami

npm npm npm

npm.io

Index

About

A light-weight service for handling secret codes such as The Konami Code within any Angular 2+ app.

Setup

Install Node

npm install ng-konami --save

Import module

  • Import NgKonamiModule by adding the following to your parent module (i.e. app.module.ts):

    import { NgKonamiModule } from 'ng-konami';
    
    @NgModule({
      ...
      imports: [
        NgKonamiModule,
        ...
      ],
      ...
    })
    export class AppModule {}

Listen for Keyboard Events

```
constructor(
  private service:NgKonamiService
) {
  
}

@HostListener('window:keyup', ['$event'])
keyEvent(event:KeyboardEvent) {
  this.events.push(event);

  this.service.listen(event);
}
```

Register Secret Code

```
constructor(
  private service:NgKonamiService
) {
  this.service.register(
    'ArrowUp,ArrowUp,ArrowDown,ArrowDown,ArrowLeft,ArrowRight,ArrowLeft,ArrowRight,b,a',
    () => {
      // do something
    }
  );
}
```

Documentation

Functions

  • register() - Register a particular sequence of keyboard characters (in CSV format).
  • listen() - Pass the keyboard events through to listen for the secret code
  • removeAll() - Remove all registered codes

Contributing

Thanks

Issues

If you find any issues feel free to open a request in the Issues tab. If I have the time I will try to solve any issues but cannot make any guarantees. Feel free to contribute yourself.

Deploy

Demo

  • Run npm install to get packages required for the demo and then run npm run demo to run locally.

Generate Docs

  • Run npm run docs:build

Update Version

Build

  • Run npm run build from root.

Test

  • Copy dist/ contents into demo/node_modules/ng-konami/
    • Run from root: cp -fr dist/* demo/node_modules/ng-konami/
  • Run ng serve from demo/
  • Run ng build --prod from demo/

NPM Release

  • Run npm publish from dist/ directory.

Update Changelog

  • Add updates to CHANGELOG.md in root.