Platformsios 10.0


SimpleKeyboard addresses a very common problem on the iOS platform: when the keyboard is shown, it can happen that the input field under it is not visible anymore. Since there is no simple or out-of-the-box general solution for this, SimpleKeyboard attempts to provide exactly that.

What makes SimpleKeyboard simple is the fact it works in every View Controller without requiring UIScrollView, AutoLayout, bottom-constraint or any other stuff that is present in different other solutions.


To run the example project, clone the repo, and run pod install from the Example directory first.

Using UIScrollView


Login screen with bottom constraint


TableView with cell containing UITextField



SimpleKeyboard is designed for flexibility, that’s why there are 3 ways you can use it:

  • Automatic: takes away all the delegate/keyboard code from your ViewController. You just specify or configure the IBOutlets and you’re done.
  • Manual: you have full control over all UITextField/UITextView in the ViewController. The keyboard still works nicely, but you have to notify SimpleKeyboard of the current input control.
  • Combined: SimpleKeyboard will manage some of the input controls for you, while the rest are left in your care.


First of all, import SimpleKeyboard into your View Controller and declare a new variable

var simpleKeyboard: SimpleKeyboard!

Now create the keyboard object in onViewDidLoad

override func viewDidLoad() {

    simpleKeyboard = SimpleKeyboard.createKeyboard(forControls: [firstTextField, secondTextField,
                                                                 firstTextView, thirdTextField],
                                                   fromViewController: self)

If there’s a need for a keyboard toolbar for a specific control (on a UITextView or a numeric keyboard), use the add function to let SimpleKeyboard manage it for you

simpleKeyboard.add(control: specificTextView, withDoneButtonKeyboard: true)
// Use selector when wanting to process pressing Done button
simpleKeyboard.add(control: lastVisibleTextField, withDoneButtonKeyboard: true, 
                   doneTarget: self, doneSelector: #selector(donePressed(_:)))

If you don’t want SimpleKeyboard to manage anything, only to correctly handle appearing and disappearing of the keyboard, then simply instantiate without any control

simpleKeyboard = SimpleKeyboard(fromViewController: self)


Override viewDidAppear and viewDidDisappear in order to start and stop using SimpleKeyboard

override func viewDidAppear(_ animated: Bool) {


override func viewWillDisappear(_ animated: Bool) {


But wait, I want the keyboard to disappear when I press Return key

You won’t need delegates for that. SimpleKeyboard implements this in an elegant way using callbacks for catching different events.
Just set up the callback like this

override func viewDidAppear(_ animated: Bool) {


    simpleKeyboard.textFieldShouldReturn = { textField in

        return true

Keep in mind this will work only for controls managed by SimpleKeyboard. All others are to be handled inside the View Controller using delegates.


What about the case when the View Controller manages different views and a UITableView, which also has different input controls in every cell? There are multiple source files with different outlets, what goes where?

It’s easy:

  • Create keyboard (with or without specific controls) and enable it
  • Implement delegate functions for begining and ending using the keyboard
  • Inside these delegates, notify SimpleKeyboard of the current view which receives
    simpleKeyboard.setActive(view: view)

    and loses


    the focus.

For more details, check NoControlsViewController.swift from the example App.

Things to consider

  • Always disable the keyboard after enabling it. Failure to do so will most likely result in a crash.
  • Do not set the delegate for a control which is being handeled by SimpleKeyboard. Depending on code flow, it could render the benefits of SimpleKeyboard useless. If you need to handle a specific UITextField/UITextView yourself, use the setActive and clearActiveView functions accordingly.


  • Swift 4.1
  • iOS 10.0 +
  • XCode 9.4+



SimpleKeyboard is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'SimpleKeyboard'


pod 'SimpleKeyboard', '~> 1.0.2'


Simply copy SimpleKeyboard.swift to your project and you’re ready to go.


Cristian Sava, [email protected]


SimpleKeyboard is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "SimpleKeyboard",
    "version": "1.0.2",
    "summary": "Simple Swift solution for not having text input controls covered by the keyboard.",
    "description": "SimpleKeyboard addresses a very common problem on the iOS platform: when the keyboard is shown, the content under it is not visible anymore. Since there is no simple or out-of-the-box solution for this, SimpleKeyboard attempts to provide exactly that.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Cristian Sava": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.0.2"
    "platforms": {
        "ios": "10.0"
    "source_files": "SimpleKeyboard/Classes/**/*",
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This