Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-hotkeys-hook

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hotkeys-hook - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

8

dist/react-hotkeys-hook.cjs.development.js

@@ -40,3 +40,5 @@ 'use strict';

_ref2$filterPreventDe = _ref2.filterPreventDefault,
filterPreventDefault = _ref2$filterPreventDe === void 0 ? true : _ref2$filterPreventDe;
filterPreventDefault = _ref2$filterPreventDe === void 0 ? true : _ref2$filterPreventDe,
_ref2$enabled = _ref2.enabled,
enabled = _ref2$enabled === void 0 ? true : _ref2$enabled;

@@ -61,2 +63,6 @@ var ref = react.useRef(null);

react.useEffect(function () {
if (!enabled) {
return;
}
if (keyup && keydown !== true) {

@@ -63,0 +69,0 @@ options.keydown = false;

2

dist/react-hotkeys-hook.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";var e,t=(e=require("hotkeys-js"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("react");t.filter=function(){return!0};var r=function(e,t){var n=e.target,r=e.srcElement,u=n&&n.tagName||r&&r.tagName;return Boolean(u&&t&&t.includes(u))};exports.useHotkeys=function(e,u,o,a){o instanceof Array&&(a=o,o=void 0);var s=o||{},c=s.enableOnTags,i=s.filter,f=s.keyup,l=s.keydown,d=s.filterPreventDefault,v=void 0===d||d,y=n.useRef(null),k=n.useCallback((function(e,t){return i&&!i(e)?!v:!(!r(e,["INPUT","TEXTAREA","SELECT"])||r(e,c))||(null===y.current||document.activeElement===y.current)&&(u(e,t),!0)}),a?[y,c,i].concat(a):[y,c,i]);return n.useEffect((function(){return f&&!0!==l&&(o.keydown=!1),t(e,o||{},k),function(){return t.unbind(e,k)}}),[k,o,e]),y},exports.useIsHotkeyPressed=function(){return t.isPressed};
"use strict";var e,t=(e=require("hotkeys-js"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("react");t.filter=function(){return!0};var r=function(e,t){var n=e.target,r=e.srcElement,u=n&&n.tagName||r&&r.tagName;return Boolean(u&&t&&t.includes(u))};exports.useHotkeys=function(e,u,o,a){o instanceof Array&&(a=o,o=void 0);var i=o||{},s=i.enableOnTags,c=i.filter,f=i.keyup,l=i.keydown,d=i.filterPreventDefault,v=void 0===d||d,y=i.enabled,k=void 0===y||y,E=n.useRef(null),b=n.useCallback((function(e,t){return c&&!c(e)?!v:!(!r(e,["INPUT","TEXTAREA","SELECT"])||r(e,s))||(null===E.current||document.activeElement===E.current)&&(u(e,t),!0)}),a?[E,s,c].concat(a):[E,s,c]);return n.useEffect((function(){if(k)return f&&!0!==l&&(o.keydown=!1),t(e,o||{},b),function(){return t.unbind(e,b)}}),[b,o,e]),E},exports.useIsHotkeyPressed=function(){return t.isPressed};
//# sourceMappingURL=react-hotkeys-hook.cjs.production.min.js.map

@@ -36,3 +36,5 @@ import hotkeys from 'hotkeys-js';

_ref2$filterPreventDe = _ref2.filterPreventDefault,
filterPreventDefault = _ref2$filterPreventDe === void 0 ? true : _ref2$filterPreventDe;
filterPreventDefault = _ref2$filterPreventDe === void 0 ? true : _ref2$filterPreventDe,
_ref2$enabled = _ref2.enabled,
enabled = _ref2$enabled === void 0 ? true : _ref2$enabled;

@@ -57,2 +59,6 @@ var ref = useRef(null);

useEffect(function () {
if (!enabled) {
return;
}
if (keyup && keydown !== true) {

@@ -59,0 +65,0 @@ options.keydown = false;

@@ -5,2 +5,3 @@ import hotkeys, { KeyHandler } from 'hotkeys-js';

export declare type Options = {
enabled?: boolean;
filter?: typeof hotkeys.filter;

@@ -7,0 +8,0 @@ filterPreventDefault?: boolean;

{
"name": "react-hotkeys-hook",
"version": "3.1.0",
"version": "3.2.0",
"repository": "https://JohannesKlauss@github.com/JohannesKlauss/react-keymap-hook.git",

@@ -31,4 +31,4 @@ "author": "Johannes Klauss",

"publish": "np",
"docz:dev": "gatsby develop",
"docz:build": "gatsby build"
"docz:dev": "docz dev",
"docz:build": "docz build"
},

@@ -59,7 +59,7 @@ "babel": {

"devDependencies": {
"@babel/core": "7.12.16",
"@babel/plugin-proposal-class-properties": "7.12.13",
"@babel/preset-env": "7.12.16",
"@babel/core": "7.13.8",
"@babel/plugin-proposal-class-properties": "7.13.0",
"@babel/preset-env": "7.13.9",
"@babel/preset-react": "7.12.13",
"@babel/preset-typescript": "7.12.16",
"@babel/preset-typescript": "7.13.0",
"@testing-library/react": "11.2.5",

@@ -74,7 +74,2 @@ "@testing-library/react-hooks": "3.4.2",

"eslint-plugin-prettier": "3.3.1",
"gatsby": "2.32.3",
"gatsby-plugin-emotion": "5.4.0",
"gatsby-plugin-sharp": "2.14.1",
"gatsby-theme-docz": "2.3.1",
"gatsby-transformer-sharp": "2.12.0",
"jest": "26.6.3",

@@ -87,3 +82,3 @@ "prettier": "2.2.1",

"tslib": "2.1.0",
"typescript": "4.1.5"
"typescript": "4.2.3"
},

@@ -90,0 +85,0 @@ "peerDependencies": {

@@ -64,2 +64,3 @@ # react-hotkeys-hook

- `keydown: boolean` Determine if want to listen on the keydown event
- `enabled: boolean` is used to prevent installation of the hotkey when set to false (default value: `true`)
- `deps: any[] = []`: The dependency array that gets appended to the memoisation of the callback. Here you define the inner

@@ -97,2 +98,13 @@ dependencies of your callback. If for example your callback actions depend on a referentially unstable value or a value

### Contributors
* [bernatmv](https://github.com/bernatmv)
* [wheeler](https://github.com/wheeler)
* [louisrli](https://github.com/louisrli)
* [jameschao](https://github.com/jameschao)
* [hmafzal](https://github.com/hmafzal)
* [godspeedelbow](https://github.com/godspeedelbow)
* [JoshuaKGoldberg](https://github.com/JoshuaKGoldberg)
* [ggascoigne](https://github.com/ggascoigne)
---

@@ -99,0 +111,0 @@

@@ -21,2 +21,3 @@ import hotkeys, { HotkeysEvent, KeyHandler } from 'hotkeys-js';

export type Options = {
enabled?: boolean;
filter?: typeof hotkeys.filter;

@@ -40,3 +41,3 @@ filterPreventDefault?: boolean;

const { enableOnTags, filter, keyup, keydown, filterPreventDefault = true } = options || {};
const { enableOnTags, filter, keyup, keydown, filterPreventDefault = true, enabled = true } = options as Options || {};
const ref = useRef<T | null>(null);

@@ -62,2 +63,6 @@

useEffect(() => {
if(!enabled) {
return
}
if (keyup && keydown !== true) {

@@ -73,2 +78,2 @@ (options as Options).keydown = false;

return ref;
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc