Repository navigation
feat(platform): deliver mobile hardware key callbacks - #1974
Merged
Merged
Conversation
1 task
Collaborator
Author
|
Not merged: this needs a design pass against main before it can be rebased.
|
houko
force-pushed
the
feat/native-keys-1352
branch
from
November 23, 2026 00:37
810c9a1 to
28fd9c9
Compare
houko
force-pushed
the
feat/native-keys-1352
branch
from
November 23, 2026 01:30
28fd9c9 to
0283471
Compare
houko
force-pushed
the
feat/native-keys-1352
branch
from
November 23, 2026 01:41
0283471 to
7a9b07a
Compare
Android: HardwareKeys.java now carries main's physical-key path, so each key reaches the app once. A down that a focused view hears is held while Go answers: PHYSICAL_KEY appends a request id that DispatchKeyDownAsync answers with EXT_KEY_REPLY (12), and only an unconsumed down runs the keymap, activation and native dispatch. Releases go to the view that heard the down, held keys follow core.KeysDown, and focus loss, teardown or a two-second watchdog release them. A runtime that predates the request reports keys as before. HarmonyOS: the Go key bridge runs view callbacks before its Go keymap, tracks repeats and original release targets, and releases keys as the lifecycle leaves active. Refs nsgo-dev#1352
houko
force-pushed
the
feat/native-keys-1352
branch
from
November 23, 2026 02:01
7a9b07a to
911a11c
Compare
Collaborator
Author
|
Reworked onto main's hardware-key path, so each key now reaches the app once:
Verified: the android CI job is green on 7a9b07a (this head only adds the HarmonyOS coverage-list fix and a rebase), including the new mobile key tests and main's |
This was referenced Nov 23, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Android now delivers
View.OnKeyDownbefore bindings and native control actions, waits asynchronously for its consume answer, and reportsOnKeyUpto the view that received the down.core.KeysDownfollows hardware keys outside native editors. Previously Android reported only shortcut bindings, so focused controls could not consume a physical key or observe its release.Depends on #1966. This branch carries that focus/activation commit rebased onto main (
cb5dc33d4); this PR's own change is810c9a1f0. The existing UIKit key dispatcher works for explicitly focused iPhone/iPad views once that dependency supplies native focus. New native regressions verify it on both idioms. Merge/rebase the dependency first; this PR does not replace its activation implementation. The software-Return and editing-key changes in #1967 and #1354 remain separate, as does native Select in #1968.Java captures each key's original focus and queues a correlated continuation. Go enqueues
DispatchKeyDownAsyncbefore reading subsequent releases, while leaving its reader available for text replies. Unconsumed events run the existing keymap/activation/native dispatch, with native Tab/arrow focus search preserved. Consumed downs still get their releases. Modifiers, repeats, focus loss, teardown and stale/dropped replies are covered; a two-second watchdog abandons pending native actions and releases observed keys rather than leaving them held.ItemKeymapcarries the held-key subscription, andEventKeyUpremains outside the event mask.HarmonyOS's Go bridge now orders callbacks before Go bindings, tracks held keys/repeats and original release targets, preserves native editor focus across late blur or unsupported plain-view focus requests, and clears held keys on lifecycle loss. The issue remains open: its committed ArkTS host still lacks native plain-view focus and returns before Go can consume an ArkUI action. The PR neither claims native consumption there nor modifies/rebuilds that host without an available SDK. These gaps remain in the roadmap.
Refs #1352.
Targets
Screenshots
None. These are hardware-key delivery and test-driver changes, verified through native callbacks, actions, focus and held-key assertions.
Verification
go tool nsgo check(host and dev client).go tool nsgo check -target ios_simulator,android,harmonyos,web -jobs 2; repeated after rebase.nsgotesttests: 168 passed, 1 existing skip.nsgotest: 6 passed, repeated after rebase. The actual engine/bridge regression covers delayed queue processing, captured focus, Go binding consumption, modifiers/repeats, original releases, editor exclusion and lifecycle loss.No physical device or native HarmonyOS acceptance was performed. The Android runtime was rebuilt locally for native tests; DEX/JAR changes are restored and left to the repository's post-merge runtime workflow. This task's simulators/emulator and AVD are removed after verification; shared devices and caches are untouched.
Checklist