Partager via


AccessibilityService.OnKeyEvent(KeyEvent) Method

Definition

Callback that allows an accessibility service to observe the key events before they are passed to the rest of the system.

[Android.Runtime.Register("onKeyEvent", "(Landroid/view/KeyEvent;)Z", "GetOnKeyEvent_Landroid_view_KeyEvent_Handler")]
protected virtual bool OnKeyEvent (Android.Views.KeyEvent? e);
[<Android.Runtime.Register("onKeyEvent", "(Landroid/view/KeyEvent;)Z", "GetOnKeyEvent_Landroid_view_KeyEvent_Handler")>]
abstract member OnKeyEvent : Android.Views.KeyEvent -> bool
override this.OnKeyEvent : Android.Views.KeyEvent -> bool

Parameters

e
KeyEvent

The event to be processed.

Returns

If true then the event will be consumed and not delivered to applications, otherwise it will be delivered as usual.

Attributes

Remarks

Callback that allows an accessibility service to observe the key events before they are passed to the rest of the system. This means that the events are first delivered here before they are passed to the device policy, the input method, or applications.

<strong>Note:</strong> It is important that key events are handled in such a way that the event stream that would be passed to the rest of the system is well-formed. For example, handling the down event but not the up event and vice versa would generate an inconsistent event stream.

<strong>Note:</strong> The key events delivered in this method are copies and modifying them will have no effect on the events that will be passed to the system. This method is intended to perform purely filtering functionality.

Java documentation for android.accessibilityservice.AccessibilityService.onKeyEvent(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