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.4.1 to 3.4.2

6

dist/index.d.ts
import { useIsHotkeyPressed } from './useIsHotkeyPressed';
import { useHotkeys, Options } from './useHotkeys';
declare const isHotkeyPressed: {
(keyCode: number): boolean;
(keyCode: string): boolean;
};
export { useHotkeys, useIsHotkeyPressed, isHotkeyPressed, Options };
export { useHotkeys, useIsHotkeyPressed, Options };

@@ -8,6 +8,2 @@ 'use strict';

/**
* @deprecated Use isHotkeyPressed instead. Will be removed version 4.
*/
function useIsHotkeyPressed() {

@@ -84,11 +80,8 @@ return hotkeys.isPressed;

};
}, [memoisedCallback, keys, enabled]);
}, [memoisedCallback, options, keys, enabled]);
return ref;
}
var isHotkeyPressed = hotkeys.isPressed;
exports.isHotkeyPressed = isHotkeyPressed;
exports.useHotkeys = useHotkeys;
exports.useIsHotkeyPressed = useIsHotkeyPressed;
//# sourceMappingURL=react-hotkeys-hook.cjs.development.js.map

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=n&&n.tagName;return Boolean(r&&t&&t.includes(r))};exports.isHotkeyPressed=t.isPressed,exports.useHotkeys=function(e,u,i,o){i instanceof Array&&(o=i,i=void 0);var s=i||{},a=s.enableOnTags,l=s.filter,c=s.keyup,f=s.keydown,d=s.filterPreventDefault,v=void 0===d||d,y=s.enabled,b=void 0===y||y,k=s.enableOnContentEditable,E=void 0!==k&&k,P=n.useRef(null),p=n.useCallback((function(e,t){var n;return l&&!l(e)?!v:!!(r(e,["INPUT","TEXTAREA","SELECT"])&&!r(e,a)||null!=(n=e.target)&&n.isContentEditable&&!E)||(null===P.current||document.activeElement===P.current)&&(u(e,t),!0)}),o?[P,a,l].concat(o):[P,a,l]);return n.useEffect((function(){if(b)return c&&!0!==f&&(i.keydown=!1),t(e,i||{},p),function(){return t.unbind(e,p)}}),[p,e,b]),P},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=n&&n.tagName;return Boolean(r&&t&&t.includes(r))};exports.useHotkeys=function(e,u,i,o){i instanceof Array&&(o=i,i=void 0);var a=i||{},l=a.enableOnTags,s=a.filter,c=a.keyup,f=a.keydown,d=a.filterPreventDefault,v=void 0===d||d,b=a.enabled,y=void 0===b||b,E=a.enableOnContentEditable,k=void 0!==E&&E,T=n.useRef(null),g=n.useCallback((function(e,t){var n;return s&&!s(e)?!v:!!(r(e,["INPUT","TEXTAREA","SELECT"])&&!r(e,l)||null!=(n=e.target)&&n.isContentEditable&&!k)||(null===T.current||document.activeElement===T.current)&&(u(e,t),!0)}),o?[T,l,s].concat(o):[T,l,s]);return n.useEffect((function(){if(y)return c&&!0!==f&&(i.keydown=!1),t(e,i||{},g),function(){return t.unbind(e,g)}}),[g,i,e,y]),T},exports.useIsHotkeyPressed=function(){return t.isPressed};
//# sourceMappingURL=react-hotkeys-hook.cjs.production.min.js.map
import hotkeys from 'hotkeys-js';
import { useRef, useCallback, useEffect } from 'react';
/**
* @deprecated Use isHotkeyPressed instead. Will be removed version 4.
*/
function useIsHotkeyPressed() {

@@ -79,9 +75,7 @@ return hotkeys.isPressed;

};
}, [memoisedCallback, keys, enabled]);
}, [memoisedCallback, options, keys, enabled]);
return ref;
}
var isHotkeyPressed = hotkeys.isPressed;
export { isHotkeyPressed, useHotkeys, useIsHotkeyPressed };
export { useHotkeys, useIsHotkeyPressed };
//# sourceMappingURL=react-hotkeys-hook.esm.js.map

@@ -1,4 +0,1 @@

/**
* @deprecated Use isHotkeyPressed instead. Will be removed version 4.
*/
export declare function useIsHotkeyPressed(): {

@@ -5,0 +2,0 @@ (keyCode: number): boolean;

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

@@ -5,0 +5,0 @@ "homepage": "https://johannesklauss.github.io/react-hotkeys-hook/",

@@ -5,2 +5,8 @@ # react-hotkeys-hook

## Documentation & Live Examples
* [Quick Start](https://react-hotkeys-hook.vercel.app/docs/intro)
* [Documentation](https://react-hotkeys-hook.vercel.app/docs/documentation/installation)
* [API](https://react-hotkeys-hook.vercel.app/docs/api/use-hotkeys)
## [Join the discussion for version 4!](https://github.com/JohannesKlauss/react-hotkeys-hook/issues/574)

@@ -11,8 +17,4 @@

## [Documentation & Live Examples](https://react-hotkeys-hook.vercel.app/)
## Installation
## [Support](https://github.com/JohannesKlauss/react-hotkeys-hook/discussions)
### Installation
```shell

@@ -30,3 +32,3 @@ npm install react-hotkeys-hook

### Usage
## Usage
```js

@@ -80,28 +82,35 @@ export const ExampleComponent = () => {

### `useIsHotkeyPressed` hook
### `isHotkeyPressed` function
The `useIsHotkeyPressed` hook just returns the `hotkeys.isPressed` function and works exactly the same.
This function allows us to check if the user is currently pressing down a key.
```ts
const isPressed = useIsHotkeyPressed();
import { isHotkeyPressed } from 'react-hotkeys-hook';
isPressed('return'); // Returns true if Return key is pressed down.
isHotkeyPressed('return'); // Returns true if Return key is pressed down.
```
### Found an issue or have a feature request?
## Support
Open up an issue or pull request and participate.
* Ask your question in the [Github Discussions]([Support](https://github.com/JohannesKlauss/react-hotkeys-hook/discussions))
* Ask your question on [StackOverflow](https://stackoverflow.com/search?page=1&tab=Relevance&q=react-hotkeys-hook)
### Local Development
If you'd like to support me, please buy me a ko-fi:
Checkout this repo, run `yarn` or `npm i` and then run the `docz:dev` script.
You can use the `docs/useHotkeys.mdx` to test the behavior of the hook. It directly imports the
`src/index.ts` file and transpiles it automatically. So you don't have to worry about. For more info
on .mdx files, check out the docz documentation: https://www.docz.site/docs/writing-mdx
![alt text](https://ucbab0164bf5c81e2a9872c53fa1.previews.dropboxusercontent.com/p/thumb/ABTE4xGDxskgsqIuOARP8_ePPukYVVLKu8I7pKjNIf9u7aJmZcTeCXXCVyQsHkviVu_5aHZWlDRVoxO_o6gEDyTngS6wyWdoRdFqzANOEgUGj5ZcREIMy33x6DKDJkg1CORDq74mJPPBmkUnIph9OKWswrc2zY3sKeNBbBbbE2Xadfy78mWAQCtRXuvwrwV-mDjxsvxrcOZo73i-9J1u2p2QYjeP7jGPCqNnuavI-18SF65Kq6KFBEyhJQ1WtqJzmEWT92alq24aQlizVSt9w10_ouccdemRwhPaSLaFvyAETrFo9gGQe21ocMjTzT9tTb7ctWZBkIi6zVvy8EKfKsTE8nB7O3tbNd2_uQrVnd-kLg/p.png?fv_content=true&size_mode=5 "Buy me a Ko-Fi")
### Authors
## Found an issue or have a feature request?
Open up an [issue](https://github.com/JohannesKlauss/react-hotkeys-hook/issues/new)
or [pull request](https://github.com/JohannesKlauss/react-hotkeys-hook/compare) and participate.
## Local Development
Checkout this repo, run `yarn` or `npm i` and then run the `test` script to test the behavior of the hook.
## Authors
* Johannes Klauss
### Contributors
## Contributors

@@ -108,0 +117,0 @@ * [bernatmv](https://github.com/bernatmv)

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