Skip to main content

OH_Input_AddKeyEventInterceptor

Function OH_Input_AddKeyEventInterceptor 

Source
pub unsafe extern "C" fn OH_Input_AddKeyEventInterceptor(
    callback: Input_KeyEventCallback,
    option: *mut Input_InterceptorOptions,
) -> Input_Result
Expand description

@brief Adds a key event interceptor. Only the first addition takes effect. Subsequent requests will return error code {@link INPUT_REPEAT_INTERCEPTOR}. Key events are intercepted only when the application gains focus.

@permission ohos.permission.INTERCEPT_INPUT_EVENT @param callback Callback used to receive key events. @param option Options for event interception. If null is passed, the default value is used. @return {@link INPUT_SUCCESS} if the operation is successful;
{@link INPUT_PERMISSION_DENIED} if permission verification fails;
{@link INPUT_PARAMETER_ERROR} if the callback is empty or no listener is added;
{@link INPUT_REPEAT_INTERCEPTOR} if an interceptor is repeatedly added;
{@link INPUT_SERVICE_EXCEPTION} if the service is abnormal. @syscap SystemCapability.MultimodalInput.Input.Core @since 12