Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help] - Can't get it working #2

Open
besarthoxhaj opened this issue May 18, 2018 · 0 comments
Open

[Help] - Can't get it working #2

besarthoxhaj opened this issue May 18, 2018 · 0 comments

Comments

@besarthoxhaj
Copy link

besarthoxhaj commented May 18, 2018

Hi @fangpenlin

I just create a new react-native project and I'm tried to implement react-native-key-commands, with not much luck though.

Here is a simple implementation. Am I doing something wrong?

Thanks for your help! :)

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import KeyCommands, { constants } from '@envoy/react-native-key-commands';

const keyCommandList = [{
  input: 'a',
  keyModifier: constants.keyModifierCommand
}];

export default class App extends React.Component {
  render() {
    return (
      <KeyCommands
        style={{flex:1}}
        onKeyCommand={this.onKeyCommand}
        keyCommands={keyCommandList}
      >
        <View style={styles.container}>
          <Text style={styles.welcome}>
            Welcome to React Native!
          </Text>
          <Text style={styles.instructions}>
            To get started, edit App.js
          </Text>
        </View>
      </KeyCommands>
    );
  }

  onKeyCommand = (evt) => {
    console.log(`evt`,evt);
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant