Comments (2)
Anyone Have A Fix For This Issue ?
from react-native-keyevent.
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)
- Registering multiple listeners at once (for example in different screens)
- Why is keyDown not supported for iOS?
- onKeyDownListener not being called when a Modal is being shown HOT 1
- Is there a Expo module API integration plan to make this library working with Expo EAS build? HOT 1
- This package is not working. HOT 1
- support windows HOT 1
- Key event is creating a click on Component HOT 12
- Maintenance of this project HOT 2
- Some times the key press event is not working on my code HOT 1
- How to use preventDefault() ? HOT 3
- Task :react-native-keyevent:verifyReleaseResources FAILED - occurred while executing gradlew assembleRelease HOT 1
- iOS build failed on release scheme only: Undefined symbols for architecture x86_64
- Comparison with react-native-hotkeys, how do we bring the best possible solution to the community?
- Add react-native abiFilters "armeabi-v7a", "x86", "x86_64", "arm64-v8a"
- react-native-keyevent not working with react-native 0.72.7?
- Pressing the center button on Android TV Remote does not work. HOT 9
- RN 0.73.2 Implementation with Kotlin HOT 8
- Not getting KeyCode in iOS when pressing button from remote control keys
- Pressing the center button on Android TV Remote works only on long press
- How to setup MainActivity.kt HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-keyevent.