react-onenterkeydown
React to enter key down events higher order component
DEPRECATED
This was originally used in a personal project along with other HoCs. However, with the realease of hooks, HoCs have become much less useful and this one in particular is very redundant and pointless to maintain. Please replace by a higher order function as follows:
const ifEnter = { if ewhich === 13 ;} ; // or even more concise, with something like ramdaconst ifEnter = ;
Live demo
You can see the simplest demo here: Live demo
Install
$ npm install --save react-onenterkeydown
Examples
Run examples:
cd examplesnpm installnpm start
Usage
react-onenterkeydown
adds an onEnterKeyDown
prop to a component with supports onKeyDown
property, such as the html input
component:
;; const logEnter = { console;} const EnhancedInput = ;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
- Beter design on example
License
See the LICENSE file for license rights and limitations (MIT).