https://github.com/rocketchat/react-native-keycommands
UIKeyCommands wrapper to React-Native.
https://github.com/rocketchat/react-native-keycommands
key-commands react-native uikeycommand
Last synced: 8 months ago
JSON representation
UIKeyCommands wrapper to React-Native.
- Host: GitHub
- URL: https://github.com/rocketchat/react-native-keycommands
- Owner: RocketChat
- Created: 2019-11-06T13:50:15.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-09-13T16:53:29.000Z (over 4 years ago)
- Last Synced: 2025-09-12T05:52:08.219Z (9 months ago)
- Topics: key-commands, react-native, uikeycommand
- Language: Objective-C
- Size: 12.7 KB
- Stars: 3
- Watchers: 6
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-native-keycommands
Use `UIKeyCommands` (iOS).
## Getting started
`$ npm install react-native-keycommands --save`
### Mostly automatic installation (RN < 0.60)
`$ react-native link react-native-keycommands`
### Manual installation (RN < 0.60)
#### iOS
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
2. Go to `node_modules` ➜ `react-native-keycommands` and add `KeyCommands.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libKeyCommands.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
4. Run your project (`Cmd+R`)<
#### Android
Not need setup.
## Usage
```javascript
import React from 'react';
import KeyCommands, { constants } from 'react-native-keycommands';
const keyCommands = [
{
input: 'a',
modifierFlags: 0, // without flags
discoverabilityTitle: 'a pressed'
},
{
input: 'a',
modifierFlags: constants.keyModifierCommand,
discoverabilityTitle: 'CMD + a pressed'
},
{
input: 'a',
modifierFlags: constants.keyModifierCommand | constants.keyModifierAlternate,
discoverabilityTitle: 'CMD + ALTERNATE + a pressed'
}
];
export default class App extends React.Component {
onKeyCommand = ({ nativeEvent }) => {
console.log('event: ', nativeEvent);
};
render() {
}
};
```