🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.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
4.0.0
to
4.1.0
+30
dist/index.cjs
'use strict';
var react = require('react');
var index = (function (ref) {
var active = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var windowKeyDown = function windowKeyDown(e) {
// Auto-focus the current input when a key is typed
if (!(e.ctrlKey || e.metaKey || e.altKey)) {
ref.current.focus();
}
};
react.useEffect(function () {
if (active) {
window.addEventListener('keydown', windowKeyDown);
} else {
window.removeEventListener('keydown', windowKeyDown);
}
return function () {
if (active) {
window.removeEventListener('keydown', windowKeyDown);
}
};
}, [active]);
});
module.exports = index;
import { useEffect } from 'react';
var index = (function (ref) {
var active = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var windowKeyDown = function windowKeyDown(e) {
// Auto-focus the current input when a key is typed
if (!(e.ctrlKey || e.metaKey || e.altKey)) {
ref.current.focus();
}
};
useEffect(function () {
if (active) {
window.addEventListener('keydown', windowKeyDown);
} else {
window.removeEventListener('keydown', windowKeyDown);
}
return function () {
if (active) {
window.removeEventListener('keydown', windowKeyDown);
}
};
}, [active]);
});
export { index as default };
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("react")):"function"==typeof define&&define.amd?define(["react"],n):(e="undefined"!=typeof globalThis?globalThis:e||self).ReactFocusOnKeyDown=n(e.React)}(this,(function(e){"use strict";return function(n){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=function(e){e.ctrlKey||e.metaKey||e.altKey||n.current.focus()};e.useEffect((function(){return t?window.addEventListener("keydown",o):window.removeEventListener("keydown",o),function(){t&&window.removeEventListener("keydown",o)}}),[t])}}));
+27
-20
{
"name": "react-focus-onkeydown",
"version": "4.0.0",
"version": "4.1.0",
"description": "React hook for getting focus of a component when a key is pressed anywhere in the page",
"main": "dist/react-focus-onkeydown.cjs.js",
"module": "dist/react-focus-onkeydown.esm.js",
"main": "dist/index.cjs",
"module": "dist/index.js",
"type": "module",
"engines": {
"node": ">=12.2"
},
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"scripts": {
"lint": "eslint 'src/*.js' 'test/*.js?(x)'",
"pretest": "npm run lint",
"test": "karma start --single-run --no-auto-watch",
"tdd": "karma start",
"lint": "eslint --cache .",
"test": "karma start karma.conf.cjs --single-run --no-auto-watch",
"tdd": "karma start karma.conf.cjs",
"build": "rollup -c",

@@ -17,3 +26,3 @@ "prepare": "npm run build"

"type": "git",
"url": "git+https://github.com/perrin4869/react-focus-onkeydown.git"
"url": "git+https://github.com/dotcore64/react-focus-onkeydown.git"
},

@@ -30,9 +39,9 @@ "files": [

"bugs": {
"url": "https://github.com/perrin4869/react-focus-onkeydown/issues"
"url": "https://github.com/dotcore64/react-focus-onkeydown/issues"
},
"homepage": "https://github.com/perrin4869/react-focus-onkeydown#readme",
"homepage": "https://github.com/dotcore64/react-focus-onkeydown#readme",
"devDependencies": {
"@babel/core": "^7.15.8",
"@babel/preset-env": "^7.15.8",
"@babel/preset-react": "^7.14.5",
"@babel/core": "^7.16.0",
"@babel/preset-env": "^7.16.0",
"@babel/preset-react": "^7.16.0",
"@rollup/plugin-babel": "^5.3.0",

@@ -44,3 +53,2 @@ "@rollup/plugin-commonjs": "^21.0.1",

"chai": "^4.3.4",
"core-js": "^3.18.3",
"coveralls": "^3.1.1",

@@ -53,9 +61,8 @@ "eslint": "^7.32.0",

"eslint-plugin-react": "^7.26.1",
"karma": "^6.3.5",
"karma": "^6.3.7",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^2.0.3",
"karma-coveralls": "^2.1.0",
"karma-firefox-launcher": "^2.1.1",
"karma-firefox-launcher": "^2.1.2",
"karma-mocha": "^2.0.1",
"karma-phantomjs-launcher": "^1.0.4",
"karma-rollup-preprocessor": "^7.0.7",

@@ -66,8 +73,8 @@ "karma-sourcemap-loader": "^0.3.8",

"prop-types": "^15.7.2",
"puppeteer": "^10.4.0",
"puppeteer": "^11.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"rollup": "^2.58.0",
"rollup": "^2.59.0",
"rollup-plugin-terser": "^7.0.2",
"sinon": "^11.1.2"
"sinon": "^12.0.0"
},

@@ -74,0 +81,0 @@ "peerDependencies": {

# react-focus-onkeydown
[![Travis][build-badge]][build]
[![Build Status][build-badge]][build]
[![npm package][npm-badge]][npm]

@@ -34,3 +34,3 @@ [![Coverage Status][coveralls-badge]][coveralls]

```javascript
import React, { useRef } from 'react';
import { useRef } from 'react';
import useFocusOnKeyDown from 'react-focus-onkeydown';

@@ -37,0 +37,0 @@

'use strict';
var react = require('react');
var index = (function (ref) {
var active = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var windowKeyDown = function windowKeyDown(e) {
// Auto-focus the current input when a key is typed
if (!(e.ctrlKey || e.metaKey || e.altKey)) {
ref.current.focus();
}
};
react.useEffect(function () {
if (active) {
window.addEventListener('keydown', windowKeyDown);
} else {
window.removeEventListener('keydown', windowKeyDown);
}
return function () {
if (active) {
window.removeEventListener('keydown', windowKeyDown);
}
};
}, [active]);
});
module.exports = index;
import { useEffect } from 'react';
var index = (function (ref) {
var active = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var windowKeyDown = function windowKeyDown(e) {
// Auto-focus the current input when a key is typed
if (!(e.ctrlKey || e.metaKey || e.altKey)) {
ref.current.focus();
}
};
useEffect(function () {
if (active) {
window.addEventListener('keydown', windowKeyDown);
} else {
window.removeEventListener('keydown', windowKeyDown);
}
return function () {
if (active) {
window.removeEventListener('keydown', windowKeyDown);
}
};
}, [active]);
});
export { index as default };
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("react")):"function"==typeof define&&define.amd?define(["react"],n):(e="undefined"!=typeof globalThis?globalThis:e||self).ReactFocusOnKeyDown=n(e.React)}(this,(function(e){"use strict";return function(n){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=function(e){e.ctrlKey||e.metaKey||e.altKey||n.current.focus()};e.useEffect((function(){return t?window.addEventListener("keydown",o):window.removeEventListener("keydown",o),function(){t&&window.removeEventListener("keydown",o)}}),[t])}}));