0.1.5 • Published 9 years ago

react-keypress v0.1.5

Weekly downloads
736
License
ISC
Repository
github
Last release
9 years ago

React keypress NPM Bower version

multi Keypress detection handlers for React.js

React wrapper for Keypress.js - http://dmauro.github.io/Keypress

Keypress is an input capture library which can be used to capture combination of keys in a simple way.

Installation

$ npm install react-keypress

or

$ bower install react-keypress

Usage

Lets say that you want to fire a function when the user press shift + enter + a:

  var React = require("react");
  var Keypress = require("react-keypress");

  React.createClass({
    sayHello() {
      alert("hello!");
    },

    render() {
      <div>
        <input type="text" onKeyPress={Keypress("shift enter a", this.sayHello)}/>
      </div>
    }
  });

API

Keypress(keysCombination, handler)

keysCombination

Type: String

This option can be either an array of strings, or a single space separated string of key names that describe the keys that make up the combo.

handler

Type: Function

This is a function that gets called everytime the keypress event for our combo is fired.

Special keys support

  • backspace
  • tab
  • num
  • enter
  • shift
  • ctrl
  • alt
  • pause
  • caps
  • esc
  • space
  • pageup
  • pagedown
  • end
  • home
  • left
  • up
  • right
  • down
  • print
  • insert
  • delete
  • cmd

Created by

Hector Leon Zarco Garcia - @zzarcon