Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@accessible/use-key
Advanced tools
npm i @accessible/use-key
A React hook for handling keydown
events on specific event.key
values. It also
normalizes non-standard event.key
values from IE to their modern equivalents.
import * as React from 'react'
import useKey from '@accessible/use-key'
const Component = () => {
const ref = React.useRef(null)
// Listens to keydown events on the `ref` above
useKey(ref, {
// Logs event when the Escape key is pressed
Escape: console.log,
// Logs "Key was pressed: Enter" to the console when Enter is pressed
Enter: (event) => console.log('Key was pressed:', event.key),
})
// Listens to keydown events on the window
useKey(window, {
// Logs event when the Escape key is pressed
Escape: console.log,
// Logs "Key was pressed: Enter" to the console when Enter is pressed
Enter: (event) => console.log('Key was pressed:', event.key),
})
return <div ref={ref} />
}
Argument | Type | Required? | Description |
---|---|---|---|
target | React.RefObject<T> | T | Window | Document | null | Yes | A React ref, element, window , or document to add the key listener to |
handlers | Record<string, (event?: KeyboardEvent) => any> | Yes | A mapping with keys matching the event.key string you want to listen on. The value for each key should be an event listener. |
void
MIT
FAQs
A React hook for handling `keydown` events on elements
The npm package @accessible/use-key receives a total of 759 weekly downloads. As such, @accessible/use-key popularity was classified as not popular.
We found that @accessible/use-key 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.