https://github.com/acrool/acrool-react-hotkey
Listener hotkey component by reactjs
https://github.com/acrool/acrool-react-hotkey
Last synced: 2 months ago
JSON representation
Listener hotkey component by reactjs
- Host: GitHub
- URL: https://github.com/acrool/acrool-react-hotkey
- Owner: acrool
- License: mit
- Created: 2024-09-24T18:41:43.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-03-08T06:38:13.000Z (4 months ago)
- Last Synced: 2025-03-26T19:03:10.474Z (3 months ago)
- Language: TypeScript
- Size: 388 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-react - Acrool React HotKey - React Hotkey (React underlying structure)
- awesome-react - Acrool React HotKey - React Hotkey (React underlying structure)
README
# Acrool React Hotkey
This is a toast message function for React development notifications[](https://www.npmjs.com/package/@acrool/react-hotkey)
[](https://github.com/acrool/@acrool/react-hotkey/blob/main/LICENSE)
[](https://github.com/acrool/react-hotkey/blob/main/LICENSE)[](https://www.npmjs.com/package/@acrool/react-hotkey)
[](https://www.npmjs.com/package/@acrool/react-hotkey)## Features
- Supports dom onKeyDown
- Supports not repeat onKeyDown
- componentOnMount add listen, componentUnMount remove listen## Install
```bash
yarn add @acrool/react-hotkey
```## Usage
```tsx
import {generateOnKeydown, HotkeyListener} from '@acrool/react-hotkey';const Example = () => {
const handleSave = () => {
// white yourr code
}
const handleCancel = () => {
// white yourr code
}
/**
* Save
*/
const handleOnKeyDown = (e) => {
generateOnKeydown('ctrl+enter', handleSave)(e);
generateOnKeydown('escape', handleCancel)(e);
};
return (<>
console.log('to setting')} />
>
);
};
```There is also a example that you can play with it:
[](https://acrool-react-hotkey.pages.dev)
## License
MIT © [Acrool](https://github.com/acrool) & [Imagine](https://github.com/imagine10255)