react-native-keycommands
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

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 LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-keycommands and add KeyCommands.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libKeyCommands.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

Not need setup.

Usage

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() {
    <KeyCommands
      style={{ flex: 1 }}
      keyCommands={keyCommands}
      onKeyCommand={this.onKeyCommand}
    />
  }
};
 

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.0.38latest

Version History

VersionDownloads (Last 7 Days)Published
2.0.38
2.0.20
2.0.10
2.0.00
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i react-native-keycommands

Weekly Downloads

8

Version

2.0.3

License

MIT

Unpacked Size

18.3 kB

Total Files

16

Last publish

Collaborators

  • djorkaeff1