https://github.com/samypesse/react-combo-keys
React declarative API to bind keyboard shortcuts
https://github.com/samypesse/react-combo-keys
javascript keyboard-shortcuts react
Last synced: 12 months ago
JSON representation
React declarative API to bind keyboard shortcuts
- Host: GitHub
- URL: https://github.com/samypesse/react-combo-keys
- Owner: SamyPesse
- License: apache-2.0
- Created: 2017-03-21T12:25:48.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T21:42:57.000Z (over 3 years ago)
- Last Synced: 2025-03-16T04:08:29.817Z (over 1 year ago)
- Topics: javascript, keyboard-shortcuts, react
- Language: TypeScript
- Size: 138 KB
- Stars: 25
- Watchers: 2
- Forks: 5
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# `react-combo-keys`
[](https://travis-ci.org/SamyPesse/react-combo-keys)
[](http://badge.fury.io/js/react-combo-keys)
Declarative API with React to bind keyboard shortcuts using Mousetrap.
### Installation
```
$ yarn add react-combo-keys
```
### Usage
```ts
import * as React from 'react';
import { useComboKeys } from 'react-combo-keys';
function SearchBar(props: {}) {
const input = Rwact.useRef();
useComboKeys({
'Mod+F': () => {
input.current.focus();
},
'Mod+': () => {
alert('Settings !')
}
}, {}, []);
return ;
}
```