Giter Club home page Giter Club logo

Comments (2)

Rob2k9 avatar Rob2k9 commented on August 17, 2024

Anyone Have A Fix For This Issue ?

from react-native-keyevent.

freddieerg avatar freddieerg commented on August 17, 2024

Anyone Have A Fix For This Issue ?

Hi Rob, I absolutely feel your pain it took me far too long to work out it was this package that was causing the dpad functionality to break. I believe RN simply uses the dpad spatial mapping natively implemented in Android however, when we implement our own onKeyDown in MainActivity and return true, we're basically saying the keypress has been dealt with and nobody else in the app needs to worry about it, this likely means the built in dpad handler is just ignoring keypresses.

To fix this your onKeyDown handler needs to return false. This will still allow this package to work normally but also tells your app that other onKeyDown handlers still need to be listening. Now, I don't know about your app but after implementing this change my back button suddenly broke. To get around this I've added a condition which will check to see if the keypress was a back button: "4". If it is a back button I return true, and this magically fixes it for reasons unknown to me.

  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    KeyEventModule.getInstance().onKeyDownEvent(keyCode, event);
    super.onKeyDown(keyCode, event);
    if(keyCode == 4) {
      return true;
    }
    return false;
  }

Hope this helps.

from react-native-keyevent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.