# SoftKeyboardInterceptionModifierNode

Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/input/key/SoftKeyboardInterceptionModifierNode.kt+class:androidx.compose.ui.input.key.SoftKeyboardInterceptionModifierNode) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.5.0) Common/AllAndroid/JVM
- Cmn

  ```
  interface SoftKeyboardInterceptionModifierNode : DelegatableNode
  ```

*** ** * ** ***

Implement this interface to create a `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.Node` that can 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.

The event is routed to the focused item. Before reaching the focused item, `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/SoftKeyboardInterceptionModifierNode#onPreInterceptKeyBeforeSoftKeyboard(androidx.compose.ui.input.key.KeyEvent)` is called for parents of the focused item. If the parents don't consume the event, [onPreSoftwareKeyboardKeyEvent]() is called for the focused item. If the event is still not consumed, `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/SoftKeyboardInterceptionModifierNode#onInterceptKeyBeforeSoftKeyboard(androidx.compose.ui.input.key.KeyEvent)` is called on the focused item's parents.

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/SoftKeyboardInterceptionModifierNode#onInterceptKeyBeforeSoftKeyboard(androidx.compose.ui.input.key.KeyEvent)(event: https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/KeyEvent)` This function is called when a `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/KeyEvent` is received by this node during the upward pass. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/SoftKeyboardInterceptionModifierNode#onPreInterceptKeyBeforeSoftKeyboard(androidx.compose.ui.input.key.KeyEvent)(event: https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/KeyEvent)` This function is called when a `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/KeyEvent` is received by this node during the downward pass. | Cmn |

### Inherited functions

From [androidx.compose.ui.node.DelegatableNode](https://developer.android.com/reference/kotlin/androidx/compose/ui/node/DelegatableNode) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/EmptySuper
https://developer.android.com/reference/kotlin/androidx/compose/ui/node/DelegatableNode#onDensityChange()()`

Invoked when the density changes for this node.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/EmptySuper
https://developer.android.com/reference/kotlin/androidx/compose/ui/node/DelegatableNode#onLayoutDirectionChange()()`

Invoked when the layout direction changes for this node.
Cmn

### Inherited properties

From [androidx.compose.ui.node.DelegatableNode](https://developer.android.com/reference/kotlin/androidx/compose/ui/node/DelegatableNode) `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.Node` `https://developer.android.com/reference/kotlin/androidx/compose/ui/node/DelegatableNode#node()`

A reference of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.Node` that holds this node's position in the node hierarchy.
Cmn

## Public functions

### onInterceptKeyBeforeSoftKeyboard

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun onInterceptKeyBeforeSoftKeyboard(event: KeyEvent): Boolean
```

This function is called when a `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/KeyEvent` is received by this node during the upward pass. While implementing this callback, return true to stop propagation of this event. If you return false, the key event will be sent to this `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/SoftKeyboardInterceptionModifierNode`'s parent.

### onPreInterceptKeyBeforeSoftKeyboard

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun onPreInterceptKeyBeforeSoftKeyboard(event: KeyEvent): Boolean
```

This function is called when a `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/KeyEvent` is received by this node during the downward pass. It gives ancestors of a focused component the chance to intercept an event. Return true to stop propagation of this event. If you return false, the event will be sent to this `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/SoftKeyboardInterceptionModifierNode`'s child. If none of the children consume the event, it will be sent back up to the root using the `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/key/SoftKeyboardInterceptionModifierNode#onPreInterceptKeyBeforeSoftKeyboard(androidx.compose.ui.input.key.KeyEvent)` function.