---
title: UITextDocumentProxy
framework: uikit
role: symbol
role_heading: Protocol
path: uikit/uitextdocumentproxy
---

# UITextDocumentProxy

An object that provides textual context to a custom keyboard.

## Declaration

```swift
@MainActor protocol UITextDocumentProxy : UIKeyInput
```

## Mentioned in

Handling text interactions in custom keyboards

## Overview

Overview Through conformance to the UIKeyInput protocol, a text document proxy enables a custom keyboard (which is based on the UIInputViewController class) to insert and delete text, to adjust the position of the insertion point, and to determine whether a text input object is empty. The text document proxy uses the keyboard’s textDocumentProxy property to do this. For more about using a text document proxy, see UIInputViewController and Creating a custom keyboard.

## Topics

### Getting the text-input mode

- [documentInputMode](uikit/uitextdocumentproxy/documentinputmode.md)

### Obtaining textual context around the insertion point

- [documentContextAfterInput](uikit/uitextdocumentproxy/documentcontextafterinput.md)
- [documentContextBeforeInput](uikit/uitextdocumentproxy/documentcontextbeforeinput.md)

### Adjusting the insertion point position

- [adjustTextPosition(byCharacterOffset:)](uikit/uitextdocumentproxy/adjusttextposition(bycharacteroffset:).md)

### Getting the selected text

- [selectedText](uikit/uitextdocumentproxy/selectedtext.md)

### Managing marked text

- [setMarkedText(_:selectedRange:)](uikit/uitextdocumentproxy/setmarkedtext(_:selectedrange:).md)
- [unmarkText()](uikit/uitextdocumentproxy/unmarktext().md)

### Distinguishing changes in the document

- [documentIdentifier](uikit/uitextdocumentproxy/documentidentifier.md)

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [UIKeyInput](uikit/uikeyinput.md)
- [UITextInputTraits](uikit/uitextinputtraits.md)

## See Also

### Custom keyboard

- [UIInputViewAudioFeedback](uikit/uiinputviewaudiofeedback.md)
- [UIInputViewController](uikit/uiinputviewcontroller.md)
- [UILexicon](uikit/uilexicon.md)
- [UILexiconEntry](uikit/uilexiconentry.md)
