injecting-mouse-and-keyboard
Installation
SKILL.md
Injecting Mouse and Keyboard — performMouseInput, performKeyInput, performMultiModalInput
Mouse and keyboard input are first-class modalities in Compose tests. Each has its own injection scope and entry point, plus a shared performMultiModalInput that combines all of them inside one batched gesture (touch, mouse, key, rotary, trackpad, indirect pointer). Coordinates remain node-local — the same rules as touch — and the entire injection state survives across perform.*Input blocks on the same node.
When to use this skill
- The test exercises a desktop or Compose Multiplatform UI that responds to clicks, hover, right-click, scroll wheel, or modifier keys.
- The test must drive a keyboard shortcut (e.g.
Ctrl+S,Shift+Tab, arrow-key navigation). - The test must verify hover-only behaviour: tooltip pop, color change on
Modifier.hoverable, mouse-only ripple state. - The test simulates a drag-and-drop with a mouse pointer.
- The test must combine modalities — for example "hover at (x, y) then click and hold while pressing
Shift".
When NOT to use this skill
- The interaction is a finger tap or drag — use
../injecting-touch-gestures/SKILL.md. Mouse is not interchangeable with touch on Android device tests. - A simple
performClick()already routes through the right modality per platform — use../clicking-and-scrolling/SKILL.md. - The test types into a
TextField— use../entering-text/SKILL.md. Key input here is for shortcuts, not text entry. - The test waits for a hover-driven animation to settle — pause the clock first per
../../synchronization/testing-animations-deterministically/SKILL.md.