Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
react-keybinding-component
Advanced tools
Readme
A React keybinding component, usable with es6, no mixin
react-keybinding-component is a component that will help you set up keybindings in your app. For the moment, only simple key events are supported (one key only, keyup
, keydown
). It's just a less dirty way of using key events instead of having care of them with componentDidMount()
in multiple components.
Import it in your project:
import KeyBinding from 'react-keybinding-component'; // ES6
var KeyBinding = require('react-keybinding-component'); // ES5
Get the eventKey keyCode and log it
<KeyBinding onKey={ (e) => { console.log(e.keyCode) } } />
Get the eventKey keyCode and log it on keyUp
on the window element
<KeyBinding onKey={ (e) => { console.log(e.keyCode) } } type='keyup' elem={ window } />
Have a look at options.
All properties are optional.
Property | Description | Default value |
---|---|---|
onKey | the function executed after a key event | () => {} |
type | keyup or keydown | 'keydown' |
target | the element you want to attach the event to, it can be an existing DOM element or a CSS selector (in that case, you will need to add a tabIndex='0' to your element, otherwise the event won't be caught) | document |
preventInputConflict | prevent onKey from firing if you have an onChange on an input, a textarea or a select | false |
preventDefault | prevent event default | false |
preventPropagation | prevent event propagation | false |
FAQs
A React keybinding component
The npm package react-keybinding-component receives a total of 1,071 weekly downloads. As such, react-keybinding-component popularity was classified as popular.
We found that react-keybinding-component demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.