
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
react-keyshortcut
Advanced tools
Keyboard Shortcuts Library, wrapper around keypress
npm install react-keyshortcut
or yarn add react-keyshortcut
.import KeyboardShortcut from 'react-keyshortcut'
.<KeyboardShortcut />
. Use combo
, callback
prop for register callback on combo key combination.KeyboardShortcutProvider
and use withShortcut
HOC to get all shortcuts as prop shortcuts
A minimal demo page can be found in example
directory.
Your project needs to use React 16.3 or later.
Add react-keyshortcut to your project by executing npm install react-keyshortcut
or yarn add react-keyshortcut
.
Here's an example of basic usage:
import React, { useState } from 'react';
import KeyboardShortcut from 'react-keyshortcut';
function MyApp() {
const [count, setCount] = useState(0);
return (
<div>
<p>{count}</p>
<KeyboardShortcut
combo={"shift s"}
callback={()=>setCount(count=>count+1)}
value={value}
/>
</div>
);
}
Here's an example of using Multiple KeyboardShortcut:
import React, { useState } from 'react';
import KeyboardShortcut from 'react-keyshortcut';
function MyApp() {
const [count, setCount] = useState(0);
return (
<div>
<p>{count}</p>
<KeyboardShortcut
combo={"shift +"}
callback={()=>setCount(count=>count+1)}
value={value}
/>
<KeyboardShortcut
combo={"shift -"}
callback={()=>setCount(count=>count-1)}
value={value}
/>
</div>
);
}
Here's an example of using KeyboardShortcutProvider and withShortcut:
// App.js
import {KeyboardShortcutProvider} from 'react-keyshortcut';
import ComponentA from './pathof/ComponentA';
import ActiveShortcuts from './pathof/ActiveShortcuts';
function App() {
const [count, setCount] = useState(0);
return (
<KeyboardShortcutProvider>
<ComponentA />
<ActiveShortcuts/>
</KeyboardShortcutProvider>
);
}
export default MyApp
// ComponentA.js
import React, { useState } from 'react';
import KeyboardShortcut from 'react-keyshortcut';
function ComponentA() {
const [count, setCount] = useState(0);
return (
<div>
<p>{count}</p>
<KeyboardShortcut
combo={"shift +"}
callback={()=>setCount(count=>count+1)}
value={value}
/>
<KeyboardShortcut
combo={"shift -"}
callback={()=>setCount(count=>count-1)}
value={value}
/>
</div>
);
}
export default ComponentA
// ActiveShortcuts.js
import React, { useState } from 'react';
import {withShortcut} from 'react-keyshortcut';
function ActiveShortcuts({shortcuts=[]}) {
return (
<div>
<p>shortcuts</p>
{shortcuts && shortcuts.map((shortcut,index)=><p key={index}>{shortcut.combo}:{shortcut.description}</p>)}
</div>
);
}
export default withShortcut(ActiveShortcuts);
Check the example directory in this repository for a full working example.
Prop name | Description | Default value | Example values |
---|---|---|---|
combo | space separated string or an array of strings of key names that describe your combo | "shift a" | |
callback | callback function executed when combo key is pressed | ()=>{} | ()=>setCount(count=>count+1) |
description | string to describe the use of combo | '' | shift a: reset background color |
The MIT License.
![]() |
Shubham Jha whoamishubham@gmail.com https://whoamishubham.github.io |
FAQs
Unknown package
The npm package react-keyshortcut receives a total of 0 weekly downloads. As such, react-keyshortcut popularity was classified as not popular.
We found that react-keyshortcut 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.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.