Skip to content

Finish voice input on D-pad center / Enter instead of canceling (Android TV)#2078

Open
PimpinPumpkin wants to merge 1 commit into
futo-org:masterfrom
PimpinPumpkin:fix/voice-input-dpad-center
Open

Finish voice input on D-pad center / Enter instead of canceling (Android TV)#2078
PimpinPumpkin wants to merge 1 commit into
futo-org:masterfrom
PimpinPumpkin:fix/voice-input-dpad-center

Conversation

@PimpinPumpkin

@PimpinPumpkin PimpinPumpkin commented Jun 3, 2026

Copy link
Copy Markdown

Summary

On Android TV (and other D-pad / remote driven devices), pressing the remote's center / "OK" button while the voice input window is open cancels dictation instead of finishing it. There is no touchscreen to "tap" the window, so there is currently no way to end dictation and submit the result using a remote.

Cause

On a device without a touchscreen the IME window is focusable, so the D-pad moves focus through the keyboard's Compose UI. When the voice input action window opens, initial focus lands on the back arrow in the action-bar header (ActionWindowBar, onBack = { closeActionWindow(true) }). Pressing D-pad center then activates that button and cancels dictation. (Tapping the window — which calls recognizerView.finish() — works on phones because touch bypasses focus.)

Fix

  • Add an open ActionWindow.onKeyEvent(KeyEvent): Boolean hook (default returns false).
  • Invoke it from UixManager via Modifier.onPreviewKeyEvent on the action-window container, so it runs before the focused composable (the back button) consumes the key.
  • VoiceInputActionWindow overrides it to treat D-pad center / Enter / numpad Enter as a tap on the window: finish recognition and submit the result.

Other action windows are unaffected (the default hook returns false, so the event propagates normally). Cancel remains available via the system Back button.

Notes

  • Reported and reproduced on an Android TV driven by a D-pad remote (the remote's OK button maps to KEYCODE_DPAD_CENTER). With the fix, center finishes & submits; the system Back button still cancels.
  • Related to Android TV Support #58 (Android TV Support).
  • onPreviewKeyEvent fires under exactly the focus condition that produces the unwanted cancel (the back button being focused), so it reliably intercepts the same event before the button does.

On devices navigated by a D-pad or remote (e.g. Android TV) the IME
window is focusable and initial focus lands on the action bar's back
button. Pressing the D-pad center then activated that button and
canceled dictation, with no way to "tap" the window to submit the
result, since there is no touchscreen.

Add an open ActionWindow.onKeyEvent hook, invoked via onPreviewKeyEvent
on the action window container so it runs before focused composables
consume the event. The voice input window overrides it to treat D-pad
center / Enter / numpad Enter as a tap on the window: finish recognition
and submit the result. Other windows are unaffected (the default
implementation returns false). Cancel remains available via the
system Back button.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant