Package io.flutter.embedding.android

## Class KeyboardManager

- java.lang.Object
- - io.flutter.embedding.android.KeyboardManager

- All Implemented Interfaces:
    `InputConnectionAdaptor.KeyboardDelegate`

      public class KeyboardManager
      extends Object
      implements InputConnectionAdaptor.KeyboardDelegate

  Processes keyboard events and cooperate with `TextInputPlugin`.

  Flutter uses asynchronous event handling to avoid blocking the UI thread, but Android requires that events are handled synchronously. So when the Android system sends new @{link KeyEvent} to Flutter, Flutter responds synchronously that the key has been handled so that it won't propagate to other components. It then uses "delayed event synthesis", where it sends the event to the framework, and if the framework responds that it has not handled the event, then this class synthesizes a new event to send to Android, without handling it this time.

  Flutter processes an Android `KeyEvent` with several components, each can choose whether to handled the event, and only unhandled events can move to the next section.

  - Keyboard: Dispatch to the `KeyboardManager.Responder`s simultaneously. After all responders have responded (asynchronously), the event is considered handled if any responders decide to handle.
  - Text input: Events are sent to `TextInputPlugin`, processed synchronously with a result of whether it is handled.
  - "Redispatch": If there's no currently focused text field in `TextInputPlugin`, or the text field does not handle the `KeyEvent` either, the `KeyEvent` will be sent back to the top of the activity's view hierachy, allowing it to be "redispatched". The `KeyboardManager` will remember this event and skip the identical event at the next encounter.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `KeyboardManager.CharacterCombiner` | Applies the given Unicode character from `KeyEvent.getUnicodeChar()` to a previously entered Unicode combining character and returns the combination of these characters if a combination exists.
    `static interface` | `KeyboardManager.Responder` | The interface for responding to a `KeyEvent` asynchronously.
    `static interface` | `KeyboardManager.ViewDelegate` | A set of interfaces that the `KeyboardManager` needs to interact with other components and the platform, and is typically implements by `FlutterView`.

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected KeyboardManager.Responder[]` | `responders` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `KeyboardManager​(KeyboardManager.ViewDelegate viewDelegate)` | Construct a `KeyboardManager`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `destroy()` |
    `boolean` | `handleEvent​(KeyEvent keyEvent)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### responders

          protected final KeyboardManager.Responder[] responders

  - ### Constructor Detail

    - #### KeyboardManager

          public KeyboardManager​(@NonNull
                                 KeyboardManager.ViewDelegate viewDelegate)

      Construct a `KeyboardManager`.
      Parameters:
        `viewDelegate` - provides a set of interfaces that the keyboard manager needs to interact with other components and the platform, and is typically implements by `FlutterView`.

  - ### Method Detail

    - #### handleEvent

          public boolean handleEvent​(@NonNull
                                     KeyEvent keyEvent)

      Specified by:
        `handleEvent` in interface `InputConnectionAdaptor.KeyboardDelegate`

    - #### destroy

          public void destroy()