add the following code to make DPAD_CENTER work. this ensure that short presses work instead of user needing to long press
const withAndroidMainActivityBody = (config) => {
// @ts-ignore
const newConfig = (0, config_plugins_1.withMainActivity)(config, (config) => {
const newSrc = [
// ... code omitted, the below lines is what I added
'@Override',
'public boolean dispatchKeyEvent(KeyEvent event) {',
' if ((event.keyCode == KeyEvent.KEYCODE_ENTER || event.keyCode == KeyEvent.KEYCODE_DPAD_CENTER) && event.getAction() == KeyEvent.ACTION_DOWN) {',
' KeyEventModule.getInstance().onKeyDownEvent(event.getKeyCode(), event);',
' return false;',
' }',
' return super.dispatchKeyEvent(event);',
'}',
];
// .... rest of code
Context:
kevinejohn/react-native-keyevent#80
Solution:
add the following code to make DPAD_CENTER work. this ensure that short presses work instead of user needing to long press
Thanks!