Skip to main content
Pinch gestures allow you to zoom and rotate content on the screen.

Pinch Gestures

TapKit supports four pinch actions:
# Zoom in (pinch out - fingers moving apart)
phone.pinch(phone.screen.center, action="pinch_out")

# Zoom out (pinch in - fingers moving together)
phone.pinch(phone.screen.center, action="pinch_in")

# Rotate clockwise
phone.pinch(phone.screen.center, action="rotate_cw")

# Rotate counter-clockwise
phone.pinch(phone.screen.center, action="rotate_ccw")

Parameters

ParameterTypeOptionsDescription
pointtuple/Point-Center point for the pinch gesture
actionstr"pinch_in", "pinch_out", "rotate_cw", "rotate_ccw"Type of pinch action

Action Types

ActionFingers MovementEffect
pinch_outMoving apartZoom in
pinch_inMoving togetherZoom out
rotate_cwRotating clockwiseRotate content clockwise
rotate_ccwRotating counter-clockwiseRotate content counter-clockwise

Use Cases

Zoom In on Content

# Zoom into the center of an image
phone.pinch(phone.screen.center, action="pinch_out")

# Zoom in multiple times for more magnification
for _ in range(3):
    phone.pinch(phone.screen.center, action="pinch_out")
    time.sleep(0.3)

Zoom Out

# Zoom out to see more content
phone.pinch(phone.screen.center, action="pinch_in")

Zoom at Specific Location

# Zoom into a specific area (e.g., top-right corner)
zoom_point = (phone.width * 3 // 4, phone.height // 4)
phone.pinch(zoom_point, action="pinch_out")

Rotate an Image

# Rotate image clockwise
phone.pinch(phone.screen.center, action="rotate_cw")

# Rotate counter-clockwise
phone.pinch(phone.screen.center, action="rotate_ccw")

Maps Navigation

# Zoom into a map location
map_center = (phone.width // 2, phone.height // 2)

# Zoom in
phone.pinch(map_center, action="pinch_out")

# Zoom out
phone.pinch(map_center, action="pinch_in")

Examples

Photo Viewer Workflow

# Open Photos and zoom into an image
phone.open_app("Photos")
time.sleep(1)

# Tap to open first photo
phone.tap((phone.width // 4, phone.height // 3))
time.sleep(0.5)

# Zoom in
phone.pinch(phone.screen.center, action="pinch_out")
time.sleep(0.3)

# Zoom in more
phone.pinch(phone.screen.center, action="pinch_out")

Reset Zoom

# Zoom out multiple times to reset
for _ in range(5):
    phone.pinch(phone.screen.center, action="pinch_in")
    time.sleep(0.2)

Tips

The pinch gesture centers on the point you specify. Choose your center carefully - zooming into the corner vs center gives very different results.
After zooming in, use pan gestures to navigate around the zoomed content.
For simpler zoom toggling, double_tap() often works as a quick zoom in/out in many apps.

Combining Gestures

A typical zoom workflow might combine multiple gestures:
# Zoom into specific area and explore
target = (phone.width * 3 // 4, phone.height // 4)

# Zoom in
phone.pinch(target, action="pinch_out")
time.sleep(0.3)

# Pan around to explore
phone.pan(phone.screen.center, direction="left", duration_ms=500)
time.sleep(0.3)

phone.pan(phone.screen.center, direction="up", duration_ms=500)
time.sleep(0.3)

# Zoom back out
phone.pinch(phone.screen.center, action="pinch_in")

Next Steps