diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index cb71470eead4dd..a65138321a8db8 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -154,6 +154,7 @@ public class com/facebook/react/ReactDelegate { public fun onHostDestroy ()V public fun onHostPause ()V public fun onHostResume ()V + public fun onKeyDown (ILandroid/view/KeyEvent;)Z public fun onNewIntent (Landroid/content/Intent;)Z public fun onWindowFocusChanged (Z)V public fun shouldShowDevMenuOrReload (ILandroid/view/KeyEvent;)Z diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java index 7079133f7d5149..45d6877405a3e6 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java @@ -147,17 +147,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { } public boolean onKeyDown(int keyCode, KeyEvent event) { - if (ReactFeatureFlags.enableBridgelessArchitecture) { - // TODO T156475655: support onKeyDown - } else { - if (getReactNativeHost().hasInstance() - && getReactNativeHost().getUseDeveloperSupport() - && keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) { - event.startTracking(); - return true; - } - } - return false; + return mReactDelegate.onKeyDown(keyCode, event); } public boolean onKeyUp(int keyCode, KeyEvent event) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java index 1cda3ab15411ce..78f34a177cdd60 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java @@ -184,6 +184,19 @@ public void onConfigurationChanged(Configuration newConfig) { } } + public boolean onKeyDown(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD + && ((ReactFeatureFlags.enableBridgelessArchitecture + && mReactHost != null + && mReactHost.getDevSupportManager() != null) + || (getReactNativeHost().hasInstance() + && getReactNativeHost().getUseDeveloperSupport()))) { + event.startTracking(); + return true; + } + return false; + } + public void loadApp() { loadApp(mMainComponentName); }