findShortcut

fun Modifier.findShortcut(onToggle: () -> Unit): Modifier(source)

Intercepts the standard find shortcut (Ctrl+F on Windows, Linux, and Android; Cmd+F on macOS and iOS) and invokes onToggle when triggered. Repeated presses toggle the find bar: onToggle is expected to flip the host's own visibility state.

Apply this directly to the TextEditor's modifier so that the handler is on the focusable node; placing it on a non-focusable ancestor does not reliably receive hardware-keyboard events on Android.

Two interception points are wired up:

  • onInterceptKeyBeforeSoftKeyboard catches the event before the Android IME gets to consume it, which is required for hardware/Bluetooth keyboards while the soft keyboard is active.

  • onPreviewKeyEvent is the standard Compose key dispatch path used on Desktop and as a fallback on Android when no IME is in play.

Both handlers consume the event so the editor doesn't see Ctrl+F as a typed character.


fun Modifier.findShortcut(state: FindState, onToggle: () -> Unit): Modifier(source)

findShortcut plus find next and previous while state has a query: F3 and Shift+F3, and Ctrl+G and Ctrl+Shift+G (Cmd on macOS and iOS). Without a query those keys pass through.