@f/keychord

    1.1.1 • Public • Published

    keychord

    Build status Git tag NPM version Code style

    Takes in a keypress/keydown/keyup event and returns a chord striE.g. 'ctrl+shift+t'

    Installation

    $ npm install @f/keychord
    

    Usage

    var keychord = require('@f/keychord')
     
    function render () {
      return <div onKeypress={handleKeypress} />
    }
     
    function handleKeypress (e) {
      switch (keychord(e)) {
        case 'enter':
          // handle enter
          break
        case 'shift+enter':
          // handle shift+enter
          break
        case 'ctrl+up':
          // handle ctrl+up
          break
      }
    }

    API

    keychord(event)

    • event - A (https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent)[KeyboardEvent] as in keypress/keyup/keydown.

    Returns: A keychord string. If only one key is being pressed, just returns the name of that key. If it is a sequence of keys, returns a string of the form 'ctrl+shift+enter'.

    License

    MIT

    Keywords

    none

    Install

    npm i @f/keychord

    DownloadsWeekly Downloads

    1

    Version

    1.1.1

    License

    MIT

    Last publish

    Collaborators

    • f