<div class='type'>Compose Modifier</div>

<a id='references'></a>


<h2 id="onpreinterceptkeybeforesoftkeyboard-onpreinterceptkeybeforesoftkeyboard">onPreInterceptKeyBeforeSoftKeyboard</h2>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun Modifier.onPreInterceptKeyBeforeSoftKeyboard(
    onPreInterceptKeyBeforeSoftKeyboard: (KeyEvent) -> Boolean
): Modifier
```


Adding this `modifier` to the `modifier` parameter of a component will allow
it to intercept hardware key events before they are sent to the software keyboard. This can be
used to intercept key input from a DPad, or physical keyboard connected to the device and is not
applicable to input that is sent to the soft keyboard via spell check or autocomplete. This
modifier is similar to `onInterceptKeyBeforeSoftKeyboard`, but allows a parent composable to
intercept the hardware key event before any child.

#### Parameters

| | |
| --- | --- |
| onPreInterceptKeyBeforeSoftKeyboard | This callback is invoked when the user interacts with the hardware keyboard. It gives ancestors of a focused component the chance to intercept a `KeyEvent`. Return true to stop propagation of this event. If you return false, the key event will be sent to this `SoftKeyboardInterceptionModifierNode`'s child. If none of the children consume the event, it will be sent back up to the root `KeyInputModifierNode` using the onKeyEvent callback, and ultimately to the software keyboard. |