Keyboard

Overview

Subjects

Keyboard Types

  • .default : Default type for current input method

  • .asciiCapable : Displays a keyboard which can enter ASCII characters

  • .numbersAndPunctuation : Displays Numbers and assorted punctuation

  • .URL : A type optimized for URL entry (shows . / .com prominently)

  • .numberPad : A number pad with locale-appropriate digits (0–9, ۰-۹, ०-९, etc.). Suitable for PIN entry

  • .phonePad : A phone pad (1–9, *, 0, #, with letters under the numbers)

  • .namePhonePad : A type optimized for entering a person’s name or phone number

  • .emailAddress : A type optimized for multiple email address entry (shows space @ . prominently)

  • .decimalPad : A number pad with a decimal point

  • .twitter : A type optimized for twitter text entry (easy access to @ #)

  • .webSearch : A default keyboard type with URL-oriented addition (shows space . prominently)

  • .asciiCapableNumberPad : A number pad (0–9) that will always be ASCII digits.

  • .alphabet : Displays a keyboard which can enter alphabetic characters, use .asciiCapable instead.

Source

Dismissing the Keyboard

Sample Codes

@FocusState private var xxxIsFocused: Bool

.keyboardType(.decimalPad)
.focused($xxxIsFocused) // trigers the state

.navigationTitle("Title")
.toolbar {
    ToolbarItemGroup(placement: .keyboard) {
        Spacer() // brought Done to the right side
        Button("Done") {
            xxxIsFocused = false
        }
    }
}

Sources

Sample Codes

Sources

Videos

Articles / Documents

See also

Last updated