Giter Club home page Giter Club logo

key-pattern-logger's Introduction

Key Pattern Logger

Simple tool that listens for keys to be hit in a certain order and calls a callback if the pattern matches.

Basic Example

keyPatternLogger = new KeyPatternLogger(
  {
    pattern: ["a", "b", "c"],
    callback: function() {
      console.log("It worked!");
    }
  }
)

Constructor Arguments

Accepts hash of parameters, pattern and callback.

  • pattern is an array of keys, can be as many or as few as you like
  • callback is a method with code that you want to execute when the pattern occurs.

Note: Modifier keys can also be checked for, e.g. "meta+a"

If the pattern consists of multiple keys, e.g. ["a", "b", "c"] the user needs to hit a, b, and c, in that order. If they hit any other key in-between, it isn’t a match.

If you only want to listen for one key, e.g. ["a"], that’s totally fine too. The callback will be called every single time someone hits the a key.

Stopping the KeyPatternLogger

If you want to stop the KeyPatternLogger from listening for matches, you can call keyPatternLogger.stop() (and start it again with keyPatternLogger.start())

Running the tests

Make sure dependencies are installed:

npm install -g mocha &
npm install

Run with coffeescript compiler

mocha --compilers coffee:coffee-script/register

key-pattern-logger's People

Stargazers

Chriztian Steinmeier avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.