pub unsafe extern "C" fn OH_Input_AddKeyEventHook(
callback: Input_KeyEventCallback,
) -> Input_ResultAvailable on crate feature
api-21 only.Expand description
Add a keyEvent interception hook function. Before using this interface, the user needs to authorize it in the settings.
ohos.permission.HOOK_KEY_EVENT
§Arguments
callback- - Hook function, keyEvent will be sent to the hook function for priority processing.
§Returns
- OH_Input_AddKeyEventHook function result code.
[
INPUT_SUCCESS] Added hook function successfully.
[INPUT_PARAMETER_ERROR] Failed to add the hook function. Reason: Parameter check failed.
[INPUT_DEVICE_NOT_SUPPORTED] Capability not supported.
[INPUT_PERMISSION_DENIED] Failed to add the hook function. Reason: Permission check failed.
[INPUT_REPEAT_INTERCEPTOR] Failed to add the hook function.
Reason: Repeatedly set the hook function. A process can only have one key hook function.
[INPUT_SERVICE_EXCEPTION] Failed to add the hook function.
Reason: Input service exception, please try again.
Available since API-level: 21