
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
react-keybinding-component
Advanced tools
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';
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' target={ window } />
Have a look at options.
All properties except onKey
are optional.
Property | Description | Default value |
---|---|---|
onKey (required) | the function executed after a key event | n/a |
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 |
preventContentEditableConflict | prevent onKey from firing if the user is editing the DOM via contenteditable="true", usually used by WYSIWYG editors | 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 2,561 weekly downloads. As such, react-keybinding-component popularity was classified as popular.
We found that react-keybinding-component demonstrated a not healthy version release cadence and project activity because the last version was released 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
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.