React OnEvent
Handle enter and spacebar event with OnEvent
OnEvent is a react stateless functional component which binds a onKeyPress eventlistener to its children component , whenever it detects a spacebar or enter on children component it calls the provided function with event as the argument.
Note: OnEvent just takes 1 children providing it multiple will result in error.
Installation
npm install react-onevent --save
Usage
;;;ReactDOM;
Props
enter
pass a function to call when enter key is pressed on the child component.
{ console.log( 'enter key pressed') } }>
space
pass a function to call when spacebar is pressed on the child component.
{ console.log( 'space key pressed') } }>
Using this ? then please star this component and feel free to contribute.
About Me
- My website (manojsinghnegi.com)
- Github (@manojsinghnegiwd)
- Twitter (@manojnegiwd)