react-onenterkeydown
React to enter key down events higher order component.
Install
$ npm install --save react-onenterkeydown
Usage
react-onenterkeydown
adds an onEnterKeyDown
prop to a component with supports onKeyDown
property, such as the html input
component:
import React, { propTypes } from 'react';
import onEnter from 'react-onenterkeydown';
const logEnter = () => {
console.log('The enter key has been pressed');
}
const EnhancedInput = onEnter("input");
const () => (
<EnhancedInput onEnterKeyDown={logEnter} />
)
If onKeyDown
is passed in addition to onEnterKeyDown
, it will execute as well after the enter event.
Props
onEnterKeyDown
Type: function
, default: undefined
Defines an event handler for when the enter key is pressed on the wrapped component
TODO
- Improve examples