Accessibility
accessibility Accessibility
Handle for the Android accessibility service instance.
Inheritance
unknown(see runtime typings)↳
EventEmitter
Table of contents
Properties
Methods
- root
- rootOrNull
- windows
- enableService
- onToast
- enableKeyEvents
- disableKeyEvents
- onKeyEvent
- onKeyDown
- onKeyUp
- clearCache
Properties
service
service(read-only):android.accessibilityservice.AccessibilityService | null
Underlying Android AccessibilityService instance, or null if unavailable.
enabled
enabled(read-only):boolean
Whether the accessibility service is currently enabled for this app.
Methods
root
root:Promise<UiObject| null>
Returns the root node of the foreground window. If the service is not running yet, the promise waits until it starts; if no root can be obtained, the promise resolves to null.
rootOrNull
rootOrNull:UiObject| null
Synchronous read of the foreground root. Returns null if the service is off or no root is available (no waiting).
windows
windows(getter):Array<AccessibilityWindow>
Currently reported accessibility windows (layers) from the service.
enableService
enableService(options?: EnableServiceOptions): Promise<android.accessibilityservice.AccessibilityService>
Requests accessibility permission if needed, then starts the service and resolves with the live AccessibilityService instance.
Parameters
options: Optional tuning (toast text, timeouts, etc.).
Returns
Promise<android.accessibilityservice.AccessibilityService>
onToast
on(event: "toast", listener: (event: ToastEvent) => void): this
Fires when another app shows a Toast.
Parameters
event: Literal"toast".listener: Callback receiving toast metadata.
Returns
this (chainable)
enableKeyEvents
enableKeyEvents(): this
After calling this, you can subscribe to key_event, key_down, and key_up (see below). Requires the appropriate capture flags where supported.
Returns
this
disableKeyEvents
disableKeyEvents(): this
Stops forwarding key events to listeners.
Returns
this
onKeyEvent
on(event: "key_event", listener: (keyCode: number, event: android.view.KeyEvent) => void): this
Generic key activity. See Android KeyEvent.
Parameters
event: Literal"key_event".listener: Callback with key code and AndroidKeyEvent.
Returns
this
onKeyDown
on(event: "key_down", listener: (keyCode: number, event: android.view.KeyEvent) => void): this
Fires whenever any key is pressed down.
Parameters
event: Literal"key_down".listener: Callback with key code andKeyEvent.
Returns
this
onKeyUp
on(event: "key_up", listener: (keyCode: number, event: android.view.KeyEvent) => void): this
Fires whenever any key is released.
Parameters
event: Literal"key_up".listener: Callback with key code andKeyEvent.
Returns
this
clearCache
clearCache(): this
Clears cached accessibility node data so the next query rebuilds the tree.
Returns
this
