react-native-keyevent icon indicating copy to clipboard operation
react-native-keyevent copied to clipboard

Event Handler Not Firing

Open timscott opened this issue 8 years ago • 7 comments

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.

timscott avatar Oct 25 '17 21:10 timscott

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

kevinejohn avatar Dec 08 '17 20:12 kevinejohn

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

godwinap avatar Feb 19 '19 11:02 godwinap

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

BigRiceEater avatar May 03 '19 08:05 BigRiceEater

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:

  • Not using Expo
  • Using an external keyboard connected via the charger port

samuelchvez avatar Oct 24 '19 17:10 samuelchvez

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 avatar Jun 30 '22 15:06 bbynog

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.

bbynog avatar Jun 30 '22 15:06 bbynog

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.

chrisribal avatar Jul 05 '22 13:07 chrisribal