Press ESC to close

Swift Keyboard Return Types

Hello friends. In this article, I will talk about the keyboard types found in Swift. If you ask what the keyboard type means, we can explain it as follows, when the keyboard is opened, there is a button in the lower right corner to close. When this button is pressed, you are actually saying that you are done with the keyboard and iOS turns off the keyboard. Actually we can change this skip button.

To change the keyboard type, we need to change the settings of the UITextField. If we want, we can do this via storyboard or with code. Since it’s easier on the storyboard, I’ll show it here. First of all, we need to specify the keyboard type in the settings of our UITextField.

You can choose one from here. Now, when you click on this uITextField, the button you have selected will appear. Of course, we should not be satisfied with this. In addition, we have to catch that this button is clicked. For this, we need to inherit the View Controller to which TextField is connected, from the UITextFiedlDelegate interface. Later, we will be able to control many properties of TextField. If we override the textFieldShouldReturn function after inheriting, this button is pressed. will drop here. You can do the necessary operations here.

class ViewController: UIViewController, UITextFieldDelegate {

    @IBOutlet weak var searchTextField: UITextField!
    override func viewDidLoad() {
        searchTextField.delegate = self
    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        return true

If you have questions, you can reach by e-mail or comment. Good work.

Leave a Reply

Your email address will not be published. Required fields are marked *