<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIInputViewController/textDocumentProxy",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIInputViewController(py)textDocumentProxy"
  },
  "title" : "textDocumentProxy"
}
-->

# textDocumentProxy

A proxy to the text input object that the custom keyboard is interacting with.

```
var textDocumentProxy: any UITextDocumentProxy { get }
```

## Discussion

This property conforms directly or indirectly to the following protocols:

- The [`UITextDocumentProxy`](/documentation/UIKit/UITextDocumentProxy) protocol provides textual context around the insertion point
- The [`UIKeyInput`](/documentation/UIKit/UIKeyInput) protocol provides the insert and delete methods, and lets you find out if the text object is empty
- The [`UITextInputTraits`](/documentation/UIKit/UITextInputTraits) protocol provides insight into the characteristics of the text input object, such as whether it requests a style of autocapitalization and which sort of keyboard it expects (for example, email address, URL, number pad, or default).

Employ this property to interact with the current text input object. For example, to insert text you would write code like this:

```objc
[self.textDocumentProxy insertText:@"hello "]; // Inserts the string "hello " at the insertion point
```

To delete text, you’d write code like this:

```objc
[self.textDocumentProxy deleteBackward];       // Deletes the character to the left of the insertion point
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)