次の方法で共有


IInputConnection.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;)Z", "GetSendKeyEvent_Landroid_view_KeyEvent_Handler:Android.Views.InputMethods.IInputConnectionInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public bool SendKeyEvent (Android.Views.KeyEvent? e);
[<Android.Runtime.Register("sendKeyEvent", "(Landroid/view/KeyEvent;)Z", "GetSendKeyEvent_Landroid_view_KeyEvent_Handler:Android.Views.InputMethods.IInputConnectionInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member SendKeyEvent : Android.Views.KeyEvent -> bool

Parameters

e
KeyEvent

The key event.

Returns

true on success, false if the input connection is no longer valid.

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.view.inputmethod.InputConnection.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

See also