KeyboardKit
About KeyboardKit
KeyboardKit is a Swift library that helps you create custom keyboard extensions for iOS
and iPadOS
. It has tools for creating keyboards that mimic native keyboards, as well as entirely custom ones. You can use any views and use the tools in any way you like.
The end result can look something like this...or entirely different:
The movie above demonstrates an extensions that mimics a native system keyboard. KeyboardKit lets you create rich system keyboards like that with support for multiple locales, multi-gestures, secondary action callouts etc.
If you're new to iOS keyboard extensions, this great guide will help you get started. You can also have a look at the demo app for inspiration.
Installation
Swift Package Manager
https://github.com/KeyboardKit/KeyboardKit.git
CocoaPods
target 'MyApp' do
pod 'KeyboardKit'
end
target 'MyKeyboard' do
pod 'KeyboardKit'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'
end
end
end
Getting Started
To build a keyboard extension with KeyboardKit, add KeyboardKit
to your project as shown above.
If you use Swift Package Manager, make sure to add KeyboardKit to your keyboard extension. You can add it to the hosting app as well, but the keyboard extension must have it.
Then, you should then inherit KeyboardInputViewController
instead of UIInputViewController
. It provides you with a lot of additional functionality, e.g. extra observables like keyboardContext
as well as services like keyboardActionHandler
, keyboardAppearance
etc.
Inheriting KeyboardInputViewController
also gives extensions access to new view lifecycle functions, autocomplete logic, extensions and more.
KeyboardInputViewController
will call viewWillSetupKeyboard
whenever the keyboard must be created or re-created due to things like screen size changes. You can then use setup(with:)
to setup your extension with any SwiftUI
view.
Setting up the view controller with a SwiftUI view will make the view the main view of the extension, inject necessary environment objects and resize the keyboard extension to fit the view.
Have a look at the demo application and read more below to see how it all fits together.
SwiftUI vs. UIKit
KeyboardKit supports both SwiftUI
and UIKit
, but SwiftUI is the main focus going forward.
The rest of this readme assumes that you're using SwiftUI. You can read more about UIKit support here.
Important about SwiftUI previews
KeyboardKit contains color and text resources that are embedded within the Swift Package. However, external SwiftUI previews can't access these resources, since the .module
bundle isn't defined outside of this package. This makes the previews crash.
Until this is solved in SwiftUI and SPM, call KeyboardPreviews.enable()
in each preview to use fake colors and texts that don't break the preview.
๐ธ๐ช
Localization
KeyboardKit is localized in the following languages:
-
๐บ๐ธ English (US - Default) -
๐ฉ๐ฐ Danish -
๐ณ๐ฑ Dutch -
๐ฌ๐ง English (UK) -
๐ซ๐ฎ Finnish -
๐ซ๐ท French -
๐ฉ๐ช German -
๐ฎ๐น Italian -
๐ณ๐ด Norwegian -
๐ช๐ธ Spanish -
๐ธ๐ช Swedish
KeyboardKit also supports localized keyboards, where the keyboard layout, secondary actions etc. behave just like they should for a certain locale.
Features
๐ฆ
Extensions & Views
Even though KeyboardKit contains a lot of features, you can use its' extensions and views alone to simplify working with keyboard extensions. For instance, there are a bunch of UITextDocumentProxy
extensions that make your life easier, and views that don't require you to use the rest of the library.
Check out the demo apps and source code for examples and more information.
๐ฅ
Keyboard Actions
KeyboardKit comes with many keyboard-specific actions, like character
inputs, emojis
, backspace
, space
, newline
, image
etc. You can even create your own actions.
๐
Keyboard Types
KeyboardKit comes with many different keyboard types, like alphabetic
, numeric
, symbolic
, emoji
etc. You can even create your own types.
๐ค
Input Sets
KeyboardKit comes with an input set engine that make it easy to create alphabetic
, numeric
and symbolic
keyboards in different languages.
โจ๏ธ
Keyboard Layouts
KeyboardKit comes with a layout engine that makes it easy to create specific keyboard layouts for various devices, orientations and locales.
๐จ
Appearances
KeyboardKit lets you style your custom keyboards with custom appearances.
๐ฏ
Callouts
KeyboardKit lets you show callout bubbles as users type, as well as secondary action callouts with optional actions.
๐ก
Autocomplete
KeyboardKit can present autocomplete suggestions as users type. The core library doesn't come with an implemented engine, but you can inject your own.
KeyboardKit Pro adds a localized autocomplete engine that provides localized suggestions.
โ
Haptic Feedback
KeyboardKit keyboards can give haptic feedback as users type.
๐
Audio Feedback
KeyboardKit keyboards can give audio feedback as users type.
Demo Application
This repository contains a demo app that demonstrates different keyboards, like alphabetical
(lowercased, uppercased and capslocked), numerical
, symbols
, emojis
and images
. It's not intended to be production ready, but rather to give you inspiration to how you can build your own keyboards.
To run the demo app, open and run the Demo/Demo.xcodeproj
project, then enable the keyboards under system settings. Enable full access to support all features, like audio and haptic feedback.
KeyboardKit Pro
KeyboardKit Pro is a license-based extensions that unlocks pro features, such as additional locales and an autocomplete engine. Going pro is also a way to support this project.
Contact
Feel free to reach out if you have questions or if you want to contribute in any way:
- E-mail: [email protected]
- Twitter: @keyboardkitapp
- Web site: getkeyboardkit.com
Sponsors and Clients
This project is proudly sponsored by the following individuals and companies:
You can support KeyboardKit by sponsoring the project on GitHub Sponsors, signing up for a KeyboardKit Pro license or hiring me for consultation.
License
KeyboardKit is available under the MIT license. See LICENSE file for more info.