🚀 Socket Launch Week Day 4:Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection.Learn more
Sign In

react-focus-onkeydown

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-focus-onkeydown - npm Package Compare versions

Comparing version
5.0.0
to
5.0.1
+24
index.js
import { useEffect } from 'react';
export default (ref, active = true) => {
const windowKeyDown = (e) => {
// Auto-focus the current input when a key is typed
if (!(e.ctrlKey || e.metaKey || e.altKey)) {
ref.current.focus();
}
};
useEffect(() => {
if (active) {
window.addEventListener('keydown', windowKeyDown);
} else {
window.removeEventListener('keydown', windowKeyDown);
}
return () => {
if (active) {
window.removeEventListener('keydown', windowKeyDown);
}
};
}, [active]);
};
+2
-2
{
"name": "react-focus-onkeydown",
"version": "5.0.0",
"version": "5.0.1",
"description": "React hook for getting focus of a component when a key is pressed anywhere in the page",

@@ -23,3 +23,3 @@ "type": "module",

"files": [
"dist"
"index.js"
],

@@ -26,0 +26,0 @@ "keywords": [