-
Notifications
You must be signed in to change notification settings - Fork 25k
Add onKeyDown/onKeyUp support to Android #54308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
@Abbondanzo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D85022034. |
1a9afb1 to
753f028
Compare
Abbondanzo
added a commit
to Abbondanzo/react-native
that referenced
this pull request
Oct 29, 2025
Summary: Adds support for `onKeyDown`/`onKeyUp` events for Android views. Since views can only retain one key listener at a time, to avoid stomping over existing implementations, this change relies upon the same logic that `ReactAndroidHWInputDeviceHelper` uses to globally dispatch key and focus events: through the `ReactRootView`. The event payload is based on [a subset of web's W3C spec](https://w3c.github.io/uievents/split/keyboard-events.html#events-keyboardevents), intentionally omitting legacy charCode/keyCode fields. The payload contains: - boolean values for all four modifier keys, - the key property [according to spec](https://w3c.github.io/uievents/split/keyboard-events.html#dom-keyboardeventinit-key), and - the code property [according to spec](https://w3c.github.io/uievents/split/keyboard-events.html#dom-keyboardeventinit-code), mapping Android keycode values to [this table](https://w3c.github.io/uievents-code/#code-value-tables) The event payload on JS also omits the `repeat` and `isComposing` fields for the sake of compatibility with desktop implementations. This change is gated behind a new feature flag introduced in facebook#54295 called `enableKeyEvents` Changelog: [Android][Added] - Add onKeyDown/onKeyUp support to Android Differential Revision: D85022034
Collaborator
|
Abbondanzo
added a commit
to Abbondanzo/react-native
that referenced
this pull request
Oct 29, 2025
Summary: Adds support for `onKeyDown`/`onKeyUp` events for Android views. Since views can only retain one key listener at a time, to avoid stomping over existing implementations, this change relies upon the same logic that `ReactAndroidHWInputDeviceHelper` uses to globally dispatch key and focus events: through the `ReactRootView`. The event payload is based on [a subset of web's W3C spec](https://w3c.github.io/uievents/split/keyboard-events.html#events-keyboardevents), intentionally omitting legacy charCode/keyCode fields. The payload contains: - boolean values for all four modifier keys, - the key property [according to spec](https://w3c.github.io/uievents/split/keyboard-events.html#dom-keyboardeventinit-key), and - the code property [according to spec](https://w3c.github.io/uievents/split/keyboard-events.html#dom-keyboardeventinit-code), mapping Android keycode values to [this table](https://w3c.github.io/uievents-code/#code-value-tables) The event payload on JS also omits the `repeat` and `isComposing` fields for the sake of compatibility with desktop implementations. This change is gated behind a new feature flag introduced in facebook#54295 called `enableKeyEvents` Changelog: [Android][Added] - Add onKeyDown/onKeyUp support to Android Differential Revision: D85022034
Abbondanzo
added a commit
to Abbondanzo/react-native
that referenced
this pull request
Oct 29, 2025
Summary: Adds support for `onKeyDown`/`onKeyUp` events for Android views. Since views can only retain one key listener at a time, to avoid stomping over existing implementations, this change relies upon the same logic that `ReactAndroidHWInputDeviceHelper` uses to globally dispatch key and focus events: through the `ReactRootView`. The event payload is based on [a subset of web's W3C spec](https://w3c.github.io/uievents/split/keyboard-events.html#events-keyboardevents), intentionally omitting legacy charCode/keyCode fields. The payload contains: - boolean values for all four modifier keys, - the key property [according to spec](https://w3c.github.io/uievents/split/keyboard-events.html#dom-keyboardeventinit-key), and - the code property [according to spec](https://w3c.github.io/uievents/split/keyboard-events.html#dom-keyboardeventinit-code), mapping Android keycode values to [this table](https://w3c.github.io/uievents-code/#code-value-tables) The event payload on JS also omits the `repeat` and `isComposing` fields for the sake of compatibility with desktop implementations. This change is gated behind a new feature flag introduced in facebook#54295 called `enableKeyEvents` Changelog: [Android][Added] - Add onKeyDown/onKeyUp support to Android Differential Revision: D85022034
Abbondanzo
added a commit
to Abbondanzo/react-native
that referenced
this pull request
Nov 4, 2025
Summary: Adds support for `onKeyDown`/`onKeyUp` events for Android views. Since views can only retain one key listener at a time, to avoid stomping over existing implementations, this change relies upon the same logic that `ReactAndroidHWInputDeviceHelper` uses to globally dispatch key and focus events: through the `ReactRootView`. The event payload is based on [a subset of web's W3C spec](https://w3c.github.io/uievents/split/keyboard-events.html#events-keyboardevents), intentionally omitting legacy charCode/keyCode fields. The payload contains: - boolean values for all four modifier keys, - the key property [according to spec](https://w3c.github.io/uievents/split/keyboard-events.html#dom-keyboardeventinit-key), and - the code property [according to spec](https://w3c.github.io/uievents/split/keyboard-events.html#dom-keyboardeventinit-code), mapping Android keycode values to [this table](https://w3c.github.io/uievents-code/#code-value-tables) The event payload on JS also omits the `repeat` and `isComposing` fields for the sake of compatibility with desktop implementations. This change is gated behind a new feature flag introduced in facebook#54295 called `enableKeyEvents` Changelog: [Android][Added] - Add onKeyDown/onKeyUp support to Android Reviewed By: alanleedev Differential Revision: D85022034
753f028 to
6efccd5
Compare
6efccd5 to
c427eaa
Compare
Abbondanzo
added a commit
to Abbondanzo/react-native
that referenced
this pull request
Nov 18, 2025
Summary: Adds support for `onKeyDown`/`onKeyUp` events for Android views. Since views can only retain one key listener at a time, to avoid stomping over existing implementations, this change relies upon the same logic that `ReactAndroidHWInputDeviceHelper` uses to globally dispatch key and focus events: through the `ReactRootView`. The event payload is based on [a subset of web's W3C spec](https://w3c.github.io/uievents/split/keyboard-events.html#events-keyboardevents), intentionally omitting legacy charCode/keyCode fields. The payload contains: - boolean values for all four modifier keys, - the key property [according to spec](https://w3c.github.io/uievents/split/keyboard-events.html#dom-keyboardeventinit-key), and - the code property [according to spec](https://w3c.github.io/uievents/split/keyboard-events.html#dom-keyboardeventinit-code), mapping Android keycode values to [this table](https://w3c.github.io/uievents-code/#code-value-tables) The event payload on JS also omits the `repeat` and `isComposing` fields for the sake of compatibility with desktop implementations. This change is gated behind a new feature flag introduced in facebook#54295 called `enableKeyEvents` Changelog: [Android][Added] - Add onKeyDown/onKeyUp support to Android Reviewed By: alanleedev, sammy-SC Differential Revision: D85022034
Summary: Adds support for `onKeyDown`/`onKeyUp` events for Android views. Since views can only retain one key listener at a time, to avoid stomping over existing implementations, this change relies upon the same logic that `ReactAndroidHWInputDeviceHelper` uses to globally dispatch key and focus events: through the `ReactRootView`. The event payload is based on [a subset of web's W3C spec](https://w3c.github.io/uievents/split/keyboard-events.html#events-keyboardevents), intentionally omitting legacy charCode/keyCode fields. The payload contains: - boolean values for all four modifier keys, - the key property [according to spec](https://w3c.github.io/uievents/split/keyboard-events.html#dom-keyboardeventinit-key), and - the code property [according to spec](https://w3c.github.io/uievents/split/keyboard-events.html#dom-keyboardeventinit-code), mapping Android keycode values to [this table](https://w3c.github.io/uievents-code/#code-value-tables) The event payload on JS also omits the `repeat` and `isComposing` fields for the sake of compatibility with desktop implementations. This change is gated behind a new feature flag introduced in facebook#54295 called `enableKeyEvents` Changelog: [Android][Added] - Add onKeyDown/onKeyUp support to Android Reviewed By: alanleedev, sammy-SC Differential Revision: D85022034
c427eaa to
719c18f
Compare
Collaborator
|
This pull request was successfully merged by @Abbondanzo in 79b09ce When will my fix make it into a release? | How to file a pick request? |
|
This pull request has been merged in 79b09ce. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
fb-exported
Merged
This PR has been merged.
meta-exported
p: Facebook
Partner: Facebook
Partner
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Adds support for
onKeyDown/onKeyUpevents for Android views. Since views can only retain one key listener at a time, to avoid stomping over existing implementations, this change relies upon the same logic thatReactAndroidHWInputDeviceHelperuses to globally dispatch key and focus events: through theReactRootView.The event payload is based on a subset of web's W3C spec, intentionally omitting legacy charCode/keyCode fields. The payload contains:
The event payload on JS also omits the
repeatandisComposingfields for the sake of compatibility with desktop implementations.This change is gated behind a new feature flag introduced in #54295 called
enableKeyEventsChangelog: [Android][Added] - Add onKeyDown/onKeyUp support to Android
Differential Revision: D85022034