# ImeKeyMonitor

Artifact: [androidx.leanback:leanback](https://developer.android.com/jetpack/androidx/releases/leanback) [View Source](https://cs.android.com/search?q=file:androidx/leanback/widget/ImeKeyMonitor.java+class:androidx.leanback.widget.ImeKeyMonitor) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

*** ** * ** ***


```
public interface ImeKeyMonitor
```

<br />

Known direct subclasses [GuidedActionAppCompatEditText](https://developer.android.com/reference/androidx/leanback/widget/GuidedActionAppCompatEditText), [GuidedActionEditText](https://developer.android.com/reference/androidx/leanback/widget/GuidedActionEditText)

|---|---|
| `https://developer.android.com/reference/androidx/leanback/widget/GuidedActionAppCompatEditText` | A custom EditText that satisfies the IME key monitoring requirements of GuidedStepFragment. |
| `https://developer.android.com/reference/androidx/leanback/widget/GuidedActionEditText` | A custom EditText that satisfies the IME key monitoring requirements of GuidedStepFragment. |

*** ** * ** ***

Interface for an EditText subclass that can delegate calls to onKeyPreIme up to a registered listener.

Used in editable actions within `https://developer.android.com/reference/androidx/leanback/app/GuidedStepFragment` to allow for custom back key handling. Specifically, this is used to implement the behavior that dismissing the IME also clears edit text focus. Clients who need to supply custom layouts for `https://developer.android.com/reference/androidx/leanback/widget/GuidedActionsStylist` with their own EditText classes should satisfy this interface in order to inherit this behavior.

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/androidx/leanback/widget/ImeKeyMonitor.ImeKeyListener` Listener interface for key events intercepted pre-IME by edit text objects. |

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/leanback/widget/ImeKeyMonitor#setImeKeyListener(androidx.leanback.widget.ImeKeyMonitor.ImeKeyListener)(https://developer.android.com/reference/androidx/leanback/widget/ImeKeyMonitor.ImeKeyListener listener)` Set the listener for this edit text object. |

## Public methods

### setImeKeyListener

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
abstract void setImeKeyListener(ImeKeyMonitor.ImeKeyListener listener)
```

Set the listener for this edit text object. The listener's onKeyPreIme method will be invoked from the host edit text's onKeyPreIme method.