Compartilhar via


InputMethod.AccessibilityInputConnection.SendKeyEvent(KeyEvent) Method

Definition

Send a key event to the process that is currently attached through this input connection.

[Android.Runtime.Register("sendKeyEvent", "(Landroid/view/KeyEvent;)V", "", ApiSince=33)]
public void SendKeyEvent (Android.Views.KeyEvent e);
[<Android.Runtime.Register("sendKeyEvent", "(Landroid/view/KeyEvent;)V", "", ApiSince=33)>]
member this.SendKeyEvent : Android.Views.KeyEvent -> unit

Parameters

Attributes

Remarks

Send a key event to the process that is currently attached through this input connection. The event will be dispatched like a normal key event, to the currently focused view; this generally is the view that is providing this InputConnection, but due to the asynchronous nature of this protocol that can not be guaranteed and the focus may have changed by the time the event is received.

This method can be used to send key events to the application. For example, an on-screen keyboard may use this method to simulate a hardware keyboard. There are three types of standard keyboards, numeric (12-key), predictive (20-key) and ALPHA (QWERTY). You can specify the keyboard type by specify the device id of the key event.

You will usually want to set the flag KeyEvent#FLAG_SOFT_KEYBOARD KeyEvent.FLAG_SOFT_KEYBOARD on all key event objects you give to this API; the flag will not be set for you.

Note that it's discouraged to send such key events in normal operation; this is mainly for use with android.text.InputType#TYPE_NULL type text fields. Use the #commitText family of methods to send text to the application instead.

Java documentation for android.accessibilityservice.InputMethod.AccessibilityInputConnection.sendKeyEvent(android.view.KeyEvent).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to