injecting-mouse-and-keyboard

Simulates mouse and keyboard input in Jetpack Compose UI tests.

1|Updated Jul 6, 2026
One-click install
npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill injecting-mouse-and-keyboard-citytexi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: injecting-mouse-and-keyboard
Source: https://github.com/citytexi/team-yg-pesonal-agent/tree/main/.claude/skills/injecting-mouse-and-keyboard
Command: npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill injecting-mouse-and-keyboard-citytexi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Testing desktop and Compose Multiplatform UIs requires simulating non-touch input like right-clicks, hover, scroll wheels, and keyboard shortcuts, which standard touch-based test APIs cannot express. ## Core Features & Use Cases - Mouse Input Injection: Use performMouseInput for clicks, right-clicks, double-clicks, long-clicks, hover enter/exit, drag-and-drop, and smooth scroll-wheel events with node-local coordinates. - Keyboard Input Injection: Use performKeyInput with keyDown/keyUp, modifier-state queries, and safe helpers like withKeyDown and withKeysDown to test shortcuts such as Ctrl+S without leaking modifier state. - Multi-Modal Input: Use performMultiModalInput to combine touch, mouse, and key scopes in one batched gesture, such as hovering while Shift is held. - Use Case: Verify a hover-driven tooltip by calling performMouseInput { enter(center) }, asserting the HoverInteraction, then exiting with an off-node offset. ## Quick Start Ask the AI to write a Compose test that right-clicks a node and asserts the context menu appears, using performMouseInput with node-local coordinates.

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 right-click in a Jetpack Compose test?▼

Use performMouseInput with the rightClick helper, which is shorthand for click(position, MouseButton.Secondary). Coordinates are node-local, so rightClick(center) clicks the center of the node under test.

How do I test a keyboard shortcut like Ctrl+S in Compose?▼

Use performKeyInput with withKeyDown(Key.CtrlLeft) { pressKey(Key.S) }. The withKeyDown helper releases the modifier in a finally block, preventing leaked key state across tests if an assertion fails.

How do I simulate mouse hover to test a tooltip in Compose?▼

Call performMouseInput { enter(center) } to emit a hover-enter event, then assert the resulting HoverInteraction or tooltip visibility. Use exit(Offset(-1f, -1f)) to mimic the cursor leaving the surface.

Why does key autorepeat not fire when I use mainClock.advanceTimeBy?▼

Repeat events are driven by the input dispatcher's event time, not the Compose frame clock. Use advanceEventTime inside the performKeyInput block; the first repeat fires after 500 ms, then every 50 ms.

When should I use performMultiModalInput instead of separate input calls?▼

Use performMultiModalInput when modalities interleave in one gesture, such as hovering while Shift is held, since all sub-scopes share injection state. For independent actions, separate performMouseInput and performKeyInput calls read more clearly.

Can I use performMouseInput to test finger taps on Android?▼

No. Mouse input is not interchangeable with touch on Android device tests. Use performClick(), which automatically resolves to a touch tap on Android and a mouse click on desktop.