
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@gentleduck/shortcut
Advanced tools
[DEPRECATED: use @gentleduck/vim instead] A lightweight React component for easily binding and handling keyboard shortcuts in your React applications.
@gentleduck/shortcutA lightweight React component for easily binding and handling keyboard shortcuts in your React applications.
useDuckShortcut hook and pass the required props to handle key combinations or sequences.Ctrl+S or Command+K with ease. The component can take a single string or an array of key combinations.Up Up Down Down Left Right B A Enter. You can define these sequences as strings or arrays.useDuckShortcut for different shortcuts without conflicts.To install the toolkit, use npm or yarn:
npm install @gentleduck/shortcut
# or
yarn add @gentleduck/shortcut
Here's a quick guide on how to use the library:
import { useDuckShortcut } from '@gentleduck/shortcut'
const App = () => {
useDuckShortcut({
keys: ['ctrl+s'], // Key combinations or sequences
onKeysPressed: () => {
console.log('Ctrl+S was pressed!')
},
})
return <div>Press Ctrl+S to trigger the shortcut</div>
}
You can handle multiple key combinations or sequences by passing them as an array:
import { useDuckShortcut } from '@gentleduck/shortcut'
const App = () => {
useDuckShortcut({
keys: ['ctrl+s', 'command+k'], // Multiple shortcuts
onKeysPressed: () => {
console.log('Ctrl+S or Command+K was pressed!')
},
})
return <div>Press Ctrl+S or Command+K to trigger the shortcut</div>
}
Here’s an API reference for @gentleduck/shortcut in MDX format, detailing the types and usage of the useDuckShortcut hook:
useDuckShortcutThe useDuckShortcut hook allows you to bind keyboard shortcuts to callback functions in your React components.
import { useDuckShortcut } from '@gentleduck/shortcut'
useDuckShortcut({
keys: /* Key combinations or sequences */,
onKeysPressed: /* Callback function */,
});
keysstring | string[]'ctrl+s', 'command+k') or key sequences (e.g., 'Up Up Down Down Left Right B A Enter').keys: 'ctrl+s'
or
keys: ['ctrl+s', 'command+k']
or
keys: 'Up Up Down Down Left Right B A Enter'
onKeysPressed() => voidonKeysPressed: () => {
console.log('Shortcut triggered!')
}
import { useDuckShortcut } from '@gentleduck/shortcut'
const App = () => {
useDuckShortcut({
keys: ['ctrl+s', 'command+k'], // Define your shortcuts
onKeysPressed: () => {
// Callback when shortcuts are pressed
console.log('Shortcut triggered!')
},
})
return <div>Press Ctrl+S or Command+K</div>
}
'ctrl+s', 'command+shift+P').'Up Up Down Down Left Right B A Enter').DuckShortcutPropsinterface DuckShortcutProps {
keys: string | string[] // Key combinations or sequences
onKeysPressed: () => void // Callback when shortcuts are pressed
}
useDuckShortcutdeclare function useDuckShortcut(props: DuckShortcutProps): void
Contributions are welcome! Please open issues and pull requests on the GitHub repository.
FAQs
[DEPRECATED: use @gentleduck/vim instead] A lightweight React component for easily binding and handling keyboard shortcuts in your React applications.
The npm package @gentleduck/shortcut receives a total of 5 weekly downloads. As such, @gentleduck/shortcut popularity was classified as not popular.
We found that @gentleduck/shortcut 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.