injecting-mouse-and-keyboard

Inject mouse and keyboard events into Jetpack Compose UI tests.

303|10|Updated May 15, 2026
One-click install
npx skills add https://github.com/skydoves/android-testing-skills --skill injecting-mouse-and-keyboard
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: injecting-mouse-and-keyboard
Source: https://github.com/skydoves/android-testing-skills/tree/main/compose/actions/injecting-mouse-and-keyboard
Command: npx skills add https://github.com/skydoves/android-testing-skills --skill injecting-mouse-and-keyboard

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the problem of reliably testing Jetpack Compose UIs that react to non-touch input such as right-clicks, hover, mouse wheel scrolling, and keyboard shortcuts (including modifier keys and key autorepeat) without flaky or platform-specific workarounds.

Core Features & Use Cases

  • Mouse input injection: performMouseInput supports click/rightClick/doubleClick/tripleClick/longClick, animated movement, hover enter/exit, smoothScroll, and drag-and-drop using node-local coordinates.
  • Keyboard input injection: performKeyInput enables keyDown/keyUp, pressKey, modifier-state assertions (Ctrl/Shift/Alt/Meta/Fn and Caps/Num/Scroll lock toggles), and repeat-key behavior via injection event time.
  • Multi-modal coordination: performMultiModalInput combines mouse and key flows (e.g., hover-then-click while holding Shift) in one batched step so state persists across sub-scopes.

Quick Start

Ask the AI to “right-click on a Compose node, assert the context menu appears, then trigger a Ctrl+S shortcut using performKeyInput.”

Frequently Asked Questions about injecting-mouse-and-keyboard

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test right-click context menus and hover tooltips in Jetpack Compose?

You can inject mouse events into Compose UI tests using performMouseInput to simulate right-clicks, hover enter/exit, and smoothScroll on specific nodes. This validates desktop-style interactions without flaky platform workarounds.

Can I test keyboard shortcuts with modifier keys like Ctrl and Shift in Compose Multiplatform?

Yes, performKeyInput enables keyDown, keyUp, and modifier-state assertions for Ctrl, Shift, Alt, and Meta keys. It safely handles modifier state using withKeyDown to prevent state leakage across tests.

What is the best way to test key autorepeat behavior in a Compose UI test?

To test key autorepeat, you use performKeyInput and manually advance injection event time via advanceEventTime. This controls the timing of repeated keyDown events to accurately simulate keyboard autorepeat behavior.

How do I simulate holding Shift while clicking and hovering in a Compose test?

You use performMultiModalInput to batch mouse and keyboard flows together. This allows you to combine hover-then-click actions while holding Shift in one step, ensuring key state persists across sub-scopes.

Why do my injected modifier keys leak state between Jetpack Compose UI tests?

Modifier state leaks when key events are not properly scoped. You should use withKeysDown or withKeyDown within performKeyInput to ensure injected modifier states are safely contained and cannot leak across tests.