<!--
{
  "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",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIInputViewController"
  },
  "title" : "UIInputViewController"
}
-->

# UIInputViewController

The primary view controller for a custom keyboard app extension.

```
@MainActor class UIInputViewController
```

## Overview

To create a custom keyboard, first subclass the [`UIInputViewController`](/documentation/UIKit/UIInputViewController) class, then add your keyboard’s user interface to the [`inputView`](/documentation/UIKit/UIInputViewController/inputView) property of your subclass. In Xcode, you can start a custom keyboard by choosing the Custom Keyboard target template.

A custom keyboard can respond to user input events in the following ways:

- Add text in the form of an unattributed <doc://com.apple.documentation/documentation/Foundation/NSString> object at the insertion point in the current text input object, by calling the [`insertText(_:)`](/documentation/UIKit/UIKeyInput/insertText(_:)) method on the [`textDocumentProxy`](/documentation/UIKit/UIInputViewController/textDocumentProxy) property. This property provides that method through its conformance to the [`UIKeyInput`](/documentation/UIKit/UIKeyInput) protocol
- Delete text in a backward direction, starting at the insertion point, by calling the [`deleteBackward()`](/documentation/UIKit/UIKeyInput/deleteBackward()) method on the [`textDocumentProxy`](/documentation/UIKit/UIInputViewController/textDocumentProxy) property.
- Switch to another keyboard in the set of user-enabled keyboards, by calling the [`advanceToNextInputMode()`](/documentation/UIKit/UIInputViewController/advanceToNextInputMode()) method.
- Dismiss the keyboard, by calling the [`dismissKeyboard()`](/documentation/UIKit/UIInputViewController/dismissKeyboard()) method.

Obtain textual context around the insertion point by reading the [`textDocumentProxy`](/documentation/UIKit/UIInputViewController/textDocumentProxy) properties [`documentContextBeforeInput`](/documentation/UIKit/UITextDocumentProxy/documentContextBeforeInput) and [`documentContextAfterInput`](/documentation/UIKit/UITextDocumentProxy/documentContextAfterInput). To find out if the current text input object is empty, call the [`hasText`](/documentation/UIKit/UIKeyInput/hasText) method on the [`textDocumentProxy`](/documentation/UIKit/UIInputViewController/textDocumentProxy) property. You can employ this textual context by considering it along with user input, to offer context-sensitive output to a document from your keyboard.

An input view controller conforms to the [`UITextInputDelegate`](/documentation/UIKit/UITextInputDelegate) protocol, allowing you to respond to changes in document content and position of the insertion point.

To present an appropriate keyboard layout, respond to the current text input object’s [`UIKeyboardType`](/documentation/UIKit/UIKeyboardType) property. For each keyboard type trait you support, change the contents of your primary view accordingly.

For more about creating a custom keyboard, read [Custom Keyboard](https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/CustomKeyboard.html#//apple_ref/doc/uid/TP40014214-CH16) in [App Extension Programming Guide](https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/index.html#//apple_ref/doc/uid/TP40014214).

## Topics

### Providing a user interface for a custom keyboard

[`inputView`](/documentation/UIKit/UIInputViewController/inputView)

The primary view for the input view controller.

### Controlling a custom keyboard

[`advanceToNextInputMode()`](/documentation/UIKit/UIInputViewController/advanceToNextInputMode())

Switches to the next keyboard in the list of user-enabled keyboards.

[`dismissKeyboard()`](/documentation/UIKit/UIInputViewController/dismissKeyboard())

Dismisses the custom keyboard from the screen.

[`handleInputModeList(from:with:)`](/documentation/UIKit/UIInputViewController/handleInputModeList(from:with:))

Supports interaction with the list of user-enabled keyboards.

### Interacting with a text input object

[`textDocumentProxy`](/documentation/UIKit/UIInputViewController/textDocumentProxy)

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

[`UITextDocumentProxy`](/documentation/UIKit/UITextDocumentProxy)

An object that provides textual context to a custom keyboard.

### Obtaining a supplementary lexicon

[`requestSupplementaryLexicon(completion:)`](/documentation/UIKit/UIInputViewController/requestSupplementaryLexicon(completion:))

Obtains a supplementary lexicon of term pairs in a custom keyboard.

### Changing the primary language of a custom keyboard

[`primaryLanguage`](/documentation/UIKit/UIInputViewController/primaryLanguage)

The primary language for a custom keyboard.

### Configuring the keyboard behaviors

[`needsInputModeSwitchKey`](/documentation/UIKit/UIInputViewController/needsInputModeSwitchKey)

A Boolean value that indicates whether the keyboard must display an input switcher key.

[`hasFullAccess`](/documentation/UIKit/UIInputViewController/hasFullAccess)

A Boolean value that indicates whether the keyboard has full access.

[`hasDictationKey`](/documentation/UIKit/UIInputViewController/hasDictationKey)

A Boolean value that indicates whether the keyboard has a dictation key.



---

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)