---
title: "moveSelection(atBoundary:in:completionHandler:)"
framework: browserenginekit
role: symbol
role_heading: Instance Method
path: "browserenginekit/betextinput/moveselection(atboundary:in:completionhandler:)"
---

# moveSelection(atBoundary:in:completionHandler:)

Moves the text-selection caret relative to the current position.

## Declaration

```swift
func moveSelection(atBoundary granularity: UITextGranularity, in direction: UITextStorageDirection, completionHandler: @escaping @Sendable () -> Void)
```

```swift
func moveSelection(atBoundary granularity: UITextGranularity, in direction: UITextStorageDirection) async
```

## Parameters

- `granularity`: The amount by which to move the caret.
- `direction`: The direction in which to move the caret, relative to the base writing direction.
- `completionHandler`: A block you call when your text view has handled the gesture.

## Mentioned in

Integrating custom browser text views with UIKit

## Discussion

Discussion If you return false from textInteractionGesture(_:shouldBeginAt:) for the gesture that moves the caret, then the text system doesn’t call this method.
