KeyboardKit
is a Swift library that helps you create keyboard extensions for iOS. It supports many keyboard actions and keyboard types and lets you create keyboards with text inputs, emojis, actions, images etc.
With KeyboardKit
, you inherit KeyboardInputViewController
instead of UIInputViewController
. This provides you with a keyboardActionHandler
that can handle taps, long presses etc. and a keyboardStackView
to which you can add components like toolbars, button rows and collection views. KeyboardKit
also provides you with tools for haptic feedback, displaying alerts on top of the keyboard etc.
The easiest way to add Sheeeeeeeeet to your project in Xcode 11 is to use Swift Package Manager:
https://github.com/danielsaidi/KeyboardKit.git
target 'HostApp' do
pod 'KeyboardKit'
end
target 'KeyboardExt' do
pod 'KeyboardKit'
end
github "danielsaidi/KeyboardKit"
To manually add KeyboardKit
to your app, clone this repository, add KeyboardKit.xcodeproj
to your project and KeyboardKit.framework
as an embedded app binary and target dependency.
With KeyboardKit
, your input view controllers should inherit from KeyboardInputViewController
instead of UIInputViewController
. It has a keyboardStackView
to which you can add components like toolbars, button rows and even collection views The keuyboard extension will automatically be resized to fit the content of this stack view.
KeyboardKit
comes with a set of actions that can be applied to your keyboard buttons, like character
s, backspace
, newline
, space
, keyboard switcher
s etc.
Checkout this guide for more information about the available actions and how to use them.
KeyboardKit
comes with the following built-in keyboard types:
alphabetic(uppercase/lowercase)
numeric
symbolic
email
emojis
custom(name)
These types are just keyboard representations, without any logic. You can bind them to a keyboard action to add buttons that switches between various keyboard types, but you have to implement the keyboards types yourself.
KeyboardKit
comes with a set of component protocols that can be combined into complete keyboard, e.g. vertical and horizontal components
, buttons
, button rows
etc.
Checkout this guide for more information about the available components and how to use them.
KeyboardKit
comes with a set of views that implement one or several of the component protocols above, e.g. vertical and horizontal components
, buttons
, button rows
etc.
Checkout this guide for more information about the available views and how to use them.
KeyboardKit supports autocomplete, which means that you can add a toolbar that displays autocomplete suggestions for the currently typed text and replaces text in your text document proxy when you tap a suggestion.
Checkout this guide for more information about how to implement autocomplete in your keyboard.
Since keyboard extensions can't display UIAlertController
s, you can use KeyboardAlert
to alert messages on top of the keyboard. You can use the built-in ToastAlert
or create a custom one.
KeyboardKit
has a HapticFeedback
type, that can be used to give the user haptic feedback as she/he uses the keyboard. HapticFeedback
defines a set of feedback types that wraps native feedback types like selection changed
, error
, success
etc.
You can enable or disable haptic feedback by providing the keyboardActionHandler
with a haptic feedback configuration. The default configuration is to disable haptic feedback.
NOTE
that you have to enable open access for the keyboard for haptic feedback to work.
KeyboardKit
has an AudioFeedback
type, that can be used to give the user audio feedback as she/he uses the keyboard. AudioFeedback
defines a set of feedback types that wraps native system sounds.
You can enable or disable audio feedback by providing the keyboardActionHandler
with a audio feedback configuration. The default configuration is to play standard audio feedback.
NOTE
that you have to enable open access for the keyboard for haptic feedback to work.
KeyboardKit
comes with a bunch of extensions that simplifies working with keyboard extensions. Many are internal and only used within the library, but some are public and can be used to handle common logic, like saving and exporting images. Check out the example app for more information.
This repository contains a demo app that demonstrates different kinds of keyboards, including:
- Alphabetical (lower + upper-case)
- Numerical
- Symbols
- Emojis
- Images
To keep the keyboard layout nice, the image switcher key is only displayed on notch devices, since they don't have to display a next keyboard button.
You have to enable "full access" in keyboard settings for haptic feedback and the image keyboard to work.
To run the demo app, open and run the KeyboardKit.xcodeproj
project.
Feel free to reach out if you have questions or if you want to contribute in any way:
- E-mail: [email protected]
- Twitter: @danielsaidi
- Web site: danielsaidi.com
KeyboardKit is available under the MIT license. See LICENSE file for more info.