1.0.1 • Published 6 years ago

alicia v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Alicia keys listener

A small utility to listen to global keypresses to use when building keyboard shortcuts/aliases in user interfaces.

Usage

Keys function take 2 or 3 parametters 1. the key to listen to, this can be the actually key, i.e. "a" or the keyCode, i.e. 97. 2. the call back function, the code you want to run when the key is clicked. 3. an optional conditional function, so that the callback can be controlled based on app state.

  const keys = require('alicia');
 
  // simple example
  function callback() {
    console.log(`You pressed the letter "a"`)
  }
  
  keys('a', callback);



  // conditional example
  function shouldWeHandleTheCallback() {
    return this.state.someValue; 
  }

  keys("a", callback, shouldWeHandleTheCallback);
  // 3rd param is a function which returns true/false
1.0.1

6 years ago

1.0.0

6 years ago