kevinejohn / react-native-keyevent

Capture external keyboard keys or remote control button events
MIT License
209 stars 96 forks source link

Event Handler Not Firing #11

Open timscott opened 6 years ago

timscott commented 6 years ago

I installed like:

yarn add react-native-keyevent
react-native link react-native-keyevent

In my code:

import KeyEvent from 'react-native-keyevent';

class MyComponent extends Component {
  componentDidMount() {
    KeyEvent.onKeyUpListener((keyCode) => {
      console.log(`Key code pressed: ${keyCode}`);
    });
  }
  render() {
    // stuff including TextInputs
  }
}

When pressing a key on the keyboard on an Android device or emulator, the event handler it not called.

kevinejohn commented 6 years ago

This library only reads external keyboard events (like bluetooth connected keyboards). Are you using the on-screen phone keyboard?

godwinap commented 5 years ago

I'm using the TV for up and down arrow buttons. It wont fire anything.

BigRiceEater commented 5 years ago

Does adb shell input text "hello" from the commandline count as an external event?

samuelchvez commented 4 years ago

Hi guys, I'm having the same problem. I've linked the library manually and I'm using React Native 0.59.9. Expanding on my comment:

bbynog commented 2 years ago

Hey guys! Did you go through the configuration part? I was getting the same behaviour, but came back to the docs and realized that I forgot to go through this part.

Hope it helps :)

bbynog commented 2 years ago

Another thing that I stumped on was that TextInputs was capturing the keyPresses before the listener, so it wasn't firing if focused on some input.

chrisribal commented 2 years ago

Hey guys! Did you go through the configuration part? I was getting the same behaviour, but came back to the docs and realized that I forgot to go through this part.

Hope it helps :)

You just saved my day! :smile: Totally overlooked the configuration part.