KeyboardKit 7.9.2

KeyboardKit 7.9.2

TestsTested โœ—
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Sep 2023
SPMSupports SPM โœ—

Maintained by Daniel Saidi.



KeyboardKit Logo

Version Swift 5.6 MIT License Twitter: @@getkeyboardkit Mastodon: @keyboardkit@techhub.social

About KeyboardKit

KeyboardKit helps you build custom keyboard extensions for iOS and iPadOS, using Swift and SwiftUI. It extends the native keyboard APIs and provides you with more functionality than is otherwise available.

KeyboardKit lets you create keyboards that mimic the native iOS keyboards in a few lines of code. These keyboards can be customized to great extent to change input keys, keyboard layout, design, behavior etc.

KeyboardKit also lets you use completely custom views together with the features that the library provides. Most of the library can be used on all major Apple platforms.

KeyboardKit supports iOS 14, macOS 11, tvOS 14 and watchOS 7, although some features are unavailable on some platforms.

Installation

KeyboardKit can be installed with the Swift Package Manager:

https://github.com/KeyboardKit/KeyboardKit.git

You can add the library to the main app, the keyboard extension and any other targets that need it. If you prefer to not have external dependencies, you can also just copy the source code into your app.

Supported Locales

KeyboardKit is localized in 61 keyboard-specific locales (read more):

๐Ÿ‡ฆ๐Ÿ‡ฑ ๐Ÿ‡ฆ๐Ÿ‡ช ๐Ÿ‡ฆ๐Ÿ‡ฒ ๐Ÿ‡ง๐Ÿ‡พ ๐Ÿ‡ง๐Ÿ‡ฌ ๐Ÿ‡ฆ๐Ÿ‡ฉ ๐Ÿณ๏ธ ๐Ÿ‡ญ๐Ÿ‡ท ๐Ÿ‡จ๐Ÿ‡ฟ ๐Ÿ‡ฉ๐Ÿ‡ฐ
๐Ÿ‡ณ๐Ÿ‡ฑ ๐Ÿ‡ง๐Ÿ‡ช ๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡ฌ๐Ÿ‡ง ๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡ช๐Ÿ‡ช ๐Ÿ‡ซ๐Ÿ‡ด ๐Ÿ‡ต๐Ÿ‡ญ ๐Ÿ‡ซ๐Ÿ‡ฎ ๐Ÿ‡ซ๐Ÿ‡ท
๐Ÿ‡ง๐Ÿ‡ช ๐Ÿ‡จ๐Ÿ‡ญ ๐Ÿ‡ฌ๐Ÿ‡ช ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ‡ฆ๐Ÿ‡น ๐Ÿ‡จ๐Ÿ‡ญ ๐Ÿ‡ฌ๐Ÿ‡ท ๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡ฎ๐Ÿ‡ฑ ๐Ÿ‡ญ๐Ÿ‡บ
๐Ÿ‡ฎ๐Ÿ‡ธ ๐Ÿ‡ฎ๐Ÿ‡ฉ ๐Ÿ‡ฎ๐Ÿ‡ช ๐Ÿ‡ฎ๐Ÿ‡น ๐Ÿ‡ฐ๐Ÿ‡ฟ ๐Ÿ‡น๐Ÿ‡ฏ ๐Ÿ‡น๐Ÿ‡ฏ ๐Ÿ‡น๐Ÿ‡ฏ ๐Ÿ‡ฑ๐Ÿ‡ป ๐Ÿ‡ฑ๐Ÿ‡น
๐Ÿ‡ฒ๐Ÿ‡ฐ ๐Ÿ‡ฒ๐Ÿ‡พ ๐Ÿ‡ฒ๐Ÿ‡น ๐Ÿ‡ฒ๐Ÿ‡ณ ๐Ÿ‡ณ๐Ÿ‡ด ๐Ÿ‡ฎ๐Ÿ‡ท ๐Ÿ‡ต๐Ÿ‡ฑ ๐Ÿ‡ต๐Ÿ‡น ๐Ÿ‡ง๐Ÿ‡ท ๐Ÿ‡ท๐Ÿ‡ด
๐Ÿ‡ท๐Ÿ‡บ ๐Ÿ‡ท๐Ÿ‡ธ ๐Ÿ‡ท๐Ÿ‡ธ ๐Ÿ‡ธ๐Ÿ‡ฐ ๐Ÿ‡ธ๐Ÿ‡ฎ ๐Ÿ‡ช๐Ÿ‡ธ ๐Ÿ‡ฐ๐Ÿ‡ช ๐Ÿ‡ธ๐Ÿ‡ช ๐Ÿ‡น๐Ÿ‡ท ๐Ÿ‡บ๐Ÿ‡ฆ
๐Ÿ‡บ๐Ÿ‡ฟ

Features

KeyboardKit comes packed features to help you build amazing and powerful keyboards:

  • ๐Ÿ’ฅ Actions - KeyboardKit has keyboard actions like characters, emojis, actions, custom ones etc. and ways to handle them.
  • ๐ŸŽจ Appearance - KeyboardKit has an appearance engine that lets you style your keyboards to great extent.
  • ๐Ÿ’ก Autocomplete - KeyboardKit can perform autocomplete and present suggestions as the user types.
  • ๐Ÿ—ฏ Callouts - KeyboardKit can show input callouts as the user types, as well as callouts with secondary actions.
  • ๐ŸŽค Dictation - (BETA) KeyboardKit can perform dictation from the keyboard extension.
  • ๐Ÿ˜Š Emojis - KeyboardKit defines emojis and emoji categories, as well as emoji keyboards.
  • โŒจ๏ธ External Keyboards - KeyboardKit lets you detect whether or not an external keyboard is connected.
  • ๐Ÿ‘‹ Feedback - KeyboardKit keyboards can give and haptic feedback feedback as the user types.
  • ๐Ÿ‘† Gestures - KeyboardKit has keyboard-specific gestures that you can use in your own keyboards.
  • ๐Ÿ”ค Input - KeyboardKit supports alphabetic, numeric, symbolic and completely custom input sets.
  • โŒจ๏ธ Keyboard - KeyboardKit supports different keyboard types, provides observable keyboard state, etc.
  • ๐Ÿ”ฃ Layout - KeyboardKit supports creating keyboard layouts for various devices, locales etc.
  • ๐ŸŒ Localization- KeyboardKit defines keyboard-specific locales with localized content and assets.
  • ๐Ÿ‘ Previews - KeyboardKit has utilites that help previewing keyboard views and components in SwiftUI.
  • โžก๏ธ Proxy - KeyboardKit extends UITextDocumentProxy and makes it do a lot more.
  • ๐Ÿš Routing - KeyboardKit lets you route text to other destinations than the main app.
  • โฌ…๏ธ RTL - KeyboardKit supports RTL (right-to-left) locales, such as Arabic, Persian, Kurdish Sorani etc.
  • โš™๏ธ Settings - KeyboardKit has tools for accessing and linking to an app's keyboard settings.

Getting Started

The online documentation has a getting-started guide that will help you get started with the library.

After installing KeyboardKit, just import KeyboardKit and make your KeyboardViewController inherit KeyboardInputViewController instead of UIInputViewController.

This gives your controller access to additional functionality, such as new lifecycle functions, observable properties, keyboard services and much more.

The default KeyboardInputViewController behavior is to setup an English SystemKeyboard keyboard. This is all the code that is required to achieve that:

import KeyboardKit

class KeyboardController: KeyboardInputViewController {}

The controller will then call viewWillSetupKeyboard() when the keyboard view should be created or updated. You can override this function and call setup(with:) to customize the default view or set up a completely custom one.

Since KeyboardKit uses plain SwiftUI, you can use any custom SwiftUI view hierarchy as your keyboard view.

For instance, here we replace the standard autocomplete toolbar with a custom toolbar:

class KeyboardViewController: KeyboardInputViewControllerย {

    func viewWillSetupKeyboard() {
        super.viewWillSetupKeyboard()
        setup { controller in
            VStack(spacing: 0) {
                MyCustomToolbar()
                SystemKeyboard(
                    controller: controller,
                    autocompleteToolbar: .none
                )
            }
        }
    }
}

and here we use a completely custom view that requires the app-specific controller type:

class KeyboardViewController: KeyboardInputViewControllerย {

    func viewWillSetupKeyboard() {
        super.viewWillSetupKeyboard()
        setup { [unowned self] in
            MyCustomKeyboard(
                controller: self
            )
        }
    }
}

When you use a custom view it's very important that it has an unowned controller reference:

struct MyCustomKeyboard: View {

    @unowned var controller: KeyboardViewController 

    var body: some View {
        ... 
    }
}

IMPORTANT When you set up a custom view, it's very important to use [unowned self] in, otherwise the strong self reference will cause a memory leak, as well as an unowned var within the view! Failing to do so will cause a memory leak.

For more information, please see the online documentation and getting-started guide.

Documentation

The online documentation has articles, code examples etc. that let you overview the various parts of the library and understand how they all connect to each other.

The online documentation is currently iOS-specific. To generate documentation for the other platforms, open the package in Xcode, select a simulator then run Product/Build Documentation.

KeyboardKit Pro

KeyboardKit Pro extends KeyboardKit with pro features, such as localized keyboards and services, autocomplete, dictation, emoji skintones, additional views etc. It lets you create fully localized keyboards with a single line of code.

Demo Application

This project has a Demo folder with a demo app that lets you try out KeyboardKit and KeyboardKit Pro. The app has an input text field and shows you how to display the state of a keyboard extension, link to system settings etc.

The demo app has 5 keyboard extensions:

  • English uses KeyboardKit and has a SystemKeyboard with the standard, English locale.
  • Unicode uses KeyboardKit and has a SystemKeyboard with unicode-based input keys.
  • Custom uses KeyboardKit and has a SystemKeyboard with custom keys, layout and appearance.
  • Pro uses KeyboardKit Pro and has a SystemKeyboard with all LRT locales, autocomplete etc.
  • ProRtl uses KeyboardKit Pro and has a SystemKeyboard with all RTL locales, autocomplete etc.

Just open and run the demo app, then enable the keyboards you want to try under System Settings. Note that you need to enable full access to try some features, like audio and haptic feedback.

Support

KeyboardKit is trusted and proudly sponsored by the following companies:

Oribi Icon phonetoroam Icon Vitalis Icon LetterKey Icon Anomaly Software Icon Milo Creative Icon

KeyboardKit is open-source and completely free, but you can sponsor this project on GitHub Sponsors, upgrade to KeyboardKit Pro or get in touch for freelance work, paid support etc.

Contact

Feel free to reach out if you have questions or if you want to contribute in any way:

License

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