KeyboardKit is a Swift SDK that lets you create fully customizable keyboards with a few lines of code, using SwiftUI.
MIT License
Bot releases are visible (Hide)
This release makes it easier to inject custom views into the SwiftUI
-based SystemKeyboard
and AutocompleteToolbar
.
There is also a new SystemKeyboardSpaceButton
which lets you present the current locale before fading to "space".
The release also adds a spacebar drag gesture and deprecates some haptic
properties as well as some system
properties in favor of the standard
naming concept (since the system behavior is the standard behavior).
AutocompleteSuggestion
is a new protocol that makes the autocomplete provider concept more general.
HapticFeedback
has a new longPressOnSpace
case.
KeyboardAppearanceProvider
is a protocol for providing button content and style.
KeyboardContext
has a new keyboardAppearanceProvider
property.
StandardKeyboardActionHandler
has new functionality for handling the space drag gesture.
StandardKeyboardAppearanceProvider
is a standard appearance provider that returns standard values.
SystemKeyboardButtonContent
is new view that extracts content logic from SystemKeyboardButton
.
SystemKeyboardButtonRowItem
can now be created with generic views.
SystemKeyboardSpaceButton
is new view that wraps SystemKeyboardSpaceButtonContent
and applies styles & gesture to it.
SystemKeyboardSpaceButtonContent
is new view that animates between a locale text and a space text.
HapticFeedback.standard
has almost no haptic feedback now, since that is the standard behavior.SystemKeyboard
now wraps the buttonBuilder
generated views in a SystemKeyboardButtonRowItem
.SystemKeyboardButton
now applies a fallback text from the new appearance provider.SystemKeyboard
button builder generates SystemKeyboardButtonContent
instead of SystemKeyboardButton
.HapticFeedback
standard cases have been deprecated, since native keyboards have almost no haptic feedback.
KeyboardAction
systemFont
is renamed to standardButtonFont
.
KeyboardAction
systemKeyboardButtonText
is renamed to standardButtonText
.
KeyboardAction
systemTextStyle
is renamed to standardButtonTextStyle
.
KeyboardType
systemKeyboardButtonText
is deprecated.
String
implements AutocompleteSuggestion
to avoid breaking changes in 3.5+. You should provide custom types, though.
Color
systemKeyboardButtonBackgroundColorDark
has been renamed to standardDarkButtonBackgroundColor
Color
systemKeyboardButtonBackgroundColorLight
has been renamed to standardLightButtonBackgroundColor
Color
systemKeyboardButtonForegroundColor
has been renamed to standardButtonForegroundColor
Color
systemKeyboardButtonShadowColor
has been renamed to standardButtonShadowColor
KeyboardAction
systemKeyboardButtonBackgroundColor
has been renamed to standardButtonBackgroundColor
KeyboardAction
systemKeyboardButtonImage
has been renamed to standardButtonImage
KeyboardAction
systemKeyboardButtonShadowColor
has been renamed to standardButtonShadowColor
KeyboardShiftState
systemImage
has been renamed to standardButtonImage
KeyboardShiftState
systemKeyboardButtonImage
was unused and has been deprecated.
KeyboardType
systemKeyboardButtonImage
has been renamed to standardButtonImage
View
systemKeyboardButtonStyle
has been renamed to standardButtonStyle
View
systemKeyboardButtonBackground
has been renamed to standardButtonBackground
View
systemKeyboardButtonFont
has been renamed to standardButtonFont
View
systemKeyboardButtonForeground
has been renamed to standardButtonForeground
View
systemKeyboardButtonShadow
has been renamed to standardButtonShadow
AutocompleteToolbarView
and AutocompleteToolbar
now use AutocompleteSuggestion
instead of String
. It makes them MUCH more powerful, so I hope this breaking change is acceptable.SystemKeyboardButtonRowItem
has been made generic.SystemKeyboard.ButtonBuilder
now returns an AnyView
since you may want to use any custom view for any button.This release adds curves and behavior changes to the callout bubbles.
CalloutStyle
now applies button frame insets when configured for a system keyboard.InputCallout
has curves between the button area and the callout.InputCalloutContext
has a new isEnabled
property that is only true for phones, since it should not be displayed on iPads.InputCalloutContext
no longer insets the button rect.SecondaryInputCallout
has curves between the button area and the callout and the design is improved.SystemInputCalloutContext
no longer insets the button rect.CalloutCurve
is a new shape that can be used to smoothen the two parts of a callout bubble.This release adds support for input callouts and secondary input callouts.
This release has new features for secondary callout actions.
KeyboardAction+SecondaryCalloutActions
specifies standard, locale-specific secondary callout actions for keyboard actions.KeyboardContext
has a new secondaryCalloutActionProvider
property.SecondaryCalloutActionProvider
is a protocol for providing secondary callout actions for keyboard actions.StandardSecondaryCalloutActionProvider
is a standard action provider that returns the standard secondary callout actions.Since the new secondary input callout, which triggers on long press, I have removed the standard long press action for all actions except backspace.
This also makes standard KeyboardKit keyboards behave more like native iOS keyboards.
This release also has breaking changes to experimental features.
KeyboardInputProvider
has been renamed to KeyboardInputSetProvider
KeyboardInputSetProvider
s properties are now context-based functionsKeyboardContext
keyboardInputProvider
has been renamed to keyboardInputSetProvider
This release contains a bunch of new features that makes the keyboard behave more like the native keyboards when typing, for instance auto-capitalization and auto-lowercasing.
This release separates action handling from behavior, which I hope makes the code cleaner and easier to test and simplifies reusing behavior outside of an action handling context.
KeyboardBehavior
specifies how a keyboard should behave.StandardKeyboardBehavior
specifies the standard behavior of a western keyboard.You can create your own behaviors as well as subclass and override parts of the standard behavior.
Note that this is an experimental feature that may have to be revisited before 4.0.
KeyboardContext
has a new preferredKeyboardType
property.KeyboardContext
has a new actionBehavior
property.StandardKeyboardBehavior
has caps-lock double tap logic.UITextDocumentProxy
has a new isCursorAtNewSentence
property.UITextDocumentProxy
has a new isCursorAtNewWord
property.UITextDocumentProxy
has a new endSentence
function that removes any space before the cursor, then closes the sentence.UITextDocumentProxy
has a new sentenceDelimiters
property.UITextDocumentProxy
has a new wordDelimiters
property.KeyboardAction
standardDoubleTapAction
is not defined for any actions anymore.KeyboardInputViewController
changeKeyboardType
has no time interval anymore.StandardKeyboardContext
initializer now has a default value for the keyboard type.KeyboardAction
endSentenceAction
has been moved to UITextDocumentProxy+EndSentence
.KeyboardAction
standardDoubleTapAction
is not used internally anymore.KeyboardContext
changeKeyboardType
is not used internally anymore.KeyboardType
canBeReplaced
is not used internally anymore.StandardKeyboardActionHandler
handleKeyboardSwitch
is renamed to handleKeyboardTypeChange
.StandardKeyboardActionHandler
preferredKeyboardType
has been moved to the keyboard behavior.These deprecations will be removed in v 4.0.
This release contains improvements to the input set functionality:
KeyboardInputProvider
protocol.StandardKeyboardInputProvider
tries to use the current locale (fallback to English) and can be inherited.StaticKeyboardInputProvider
uses three static input sets.InputSet+English
has been renamed to InputSet+Locale
and has more sets.InputSet+Locale
extension has support for basic English, German, Italian and Swedish.StandardKeyboardInputProvider
is used by default in the context, but you can change this at anytime.The release also introduces a new "keyboard layout" concept, where a keyboard layout is an input set with surrounding actions:
KeyboardLayout
struct.KeyboardLayoutProvider
protocol.
StandardKeyboardLayoutProvider
uses the current context and can be inherited.StaticKeyboardLayoutProvider
uses a static layout that is provided at init.StandardKeyboardLayoutProvider
is used by default in the context, but you can change this at anytime.There are new properties in the KeyboardContext
.
This release also makes it easier to resolve system keyboard dimensions:
CGFloat+Keyboard
has utils to resolve the standard keyboard row height.KeyboardStackViewComponent
s use this new standard height as default height.UIEdgeInsets+Keyboard
has utils to resolve the standard keyboard row item insets.KeyboardButtonRowComponent
s use these new standard insets as default insets.The demos have been updated with these changes.
@unowned
to fix a memory leak.CGFloat+KeyboardDimensions
is deprecated and will be removed in 4.0.KeyboardContext
's controller
is now deprecated and will be removed in 4.0 .Usage is strongly discouraged. Use the context instead.KeyboardContext
has new properties to make the new input and layout additions possible. If you have created your own context, you will have to add these.This version contains new features:
EmojiCategory
is now Codable
.EmojiCategory
has a fallbackDisplayEmoji
that is used as system button text if no custom button image used.KeyboardAction
now has a standard tap action for .emojiCategory
.KeyboardContext
now has an emojiCategory
property.This version contains new protocols and classes:
KeyboardInputViewController
has new, empty performAutocomplete
and resetAutocomplete
functions that are called by the system at proper times.AutocompleteSuggestions
typealias makes the autocomplete apis cleaner.AutocompleteContext
protocol that can be used to manage suggestions.StandardAutocompleteContext
implementation of AutocompleteContext
.UITextDocumentProxy
property to check if the proxy cursor is at the end of the current word.Bug fixes:
This version removes all previously deprecated parts of the library and adds improved support for SwiftUI and iOS 13.
If you upgrade from an older version to 3.0
and have many breaking changes, upgrading to 2.9
first provides deprecation help that may make the transition easier.
There is a new KeyboardContext
, which provides important contextual information.
StandardKeyboardContext
is the standard, non-observable implementation.ObservableKeyboardContext
is an iOS 13+ required, observable implementation.StandardKeyboardActionHandler
now automatically handles keyboard type switching and only delays if an action has a double-tap action.StandardKeyboardActionHandler
now automatically switches to certain keyboards after certain actions, as defined by handleKeyboardSwitch(after:on:)
and preferredKeyboardType(after:on:)
.There are new KeyboardAction
types and properties:
.control
represents the system..systemImage
can be used with SF Symbols..systemFont
and .systemTextStyle
provide system look information.There is a new System
namespace with utils to help you build native-imitating system keyboards.
There is a new KeyboardInputSet
concept that will simplify building language-specific keyboards. For now, it contains English characters, numerics and symbols.
The demo project contains a new KeyboardKitSwiftUIPreviews
in which you can preview KeyboardKitSwiftUI views.
KeyboardImageButton
supports the new systemImage
action.KeyboardInputViewController
deviceOrientation
has been converted to a general UIInputViewController
extension.setupNextKeyboardButton
has been converted to a general UIInputViewController
extension.KeyboardInputViewController
has a new keyboardContext
property.
StandardKeyboardContext
is used by default, whenever a keyboard extension is created.
ObservableKeyboardContext
is used by whenever a keyboard switches over to use SwiftUI.
KeyboardInputViewController
keyboardActionHandler
has been moved to KeyboardContext
.
KeyboardInputViewController
canChangeKeyboardType
has been moved to KeyboardType
.
KeyboardInputViewController
changeKeyboardType
has been moved to KeyboardContext
.
KeyboardInputViewController
changeKeyboardTypeDelay
is now an argument in changeKeyboardType
.
KeyboardInputViewController
keyboardType
has been moved to the context.
AutocompleteToolbar
has been renamed to AutocompleteToolbarView
.
EmojiCategory.frequents
has been renamed to frequent
.
KeyboardActionHandler
now requires canHandle(_:on:)
to be implemented.
KeyboardAction
has new action types.
KeyboardAction
has fewer isXXX
properties.
KeyboardAction
.capsLock
and shiftDown
are now part of KeyboardAction.shift
.
KeyboardActionRow.from
has been changed to an initializer.
KeyboardActionRows.from
has been changed to an initializer.
KeyboardImageActions
has been converted to a KeyboardActionRow+Images
extension initializer.
KeyboardToolbar
has been renamed to KeyboardToolbarView
.
The shouldChangeToAlphabeticLowercase
has been replaced with the automatic switching mentioned above.
The isKeyboardEnabled
function now uses a for
as external argument name.
AutocompleteBugFixTimer
AutocompleteSuggestionProvider
provideAutocompleteSuggestions
KeyboardAction
switchKeyboard
KeyboardAction
switchToKeyboard
KeyboardAction
standardInputViewControllerAction
KeyboardAction
standardTextDocumentProxyAction
KeyboardActionHandler
handleTap/Repeat/LongPress
KeyboardActionHandler
handle
gesture on UIView
KeyboardInputViewController
addSwitchKeyboardGesture
PersistedKeyboardSetting
init with keyStandardKeyboardActionHandler
init
with feedback instancesStandardKeyboardActionHandler
action
for viewStandardKeyboardActionHandler
animationButtonTap
StandardKeyboardActionHandler
giveHapticFeedbackForLongPress/Repeat/Tap
StandardKeyboardActionHandler
longPress/repeat/tapAction
for viewStandardKeyboardActionHandler
handleLongPress/Repeat/Tap
StandardKeyboardActionHandler
triggerAudio/HapticFeedback
UIColor
clearTappable
UIInputViewController
createAutocompleteBugFixTimer
UIView
add/removeLongPress/Repeating/TapAction
isKeyboardEnabled
global functionThis version adds an .emoji
keyboard action, which can be used if you need to separate characters from emojis.
It also extracts the logic of KeyboardAction
standardTapAction
into
standardTapActionForController
standardTapActionForProxy
which makes it possible to use the standard function in more ways.
This version also makes actions
of KeyboardCollectionView
mutable, causing changes to this property to refresh the view.
This is the last minor version before 3.0
, which will remove a bunch of deprecated members.
This version adds more features, fixes some bugs and deprecates many parts of the library.
A big change, which is not fully covered in these notes, is that KeyboardInputViewController
and StandardKeyboardActionHandler
now handles changing keyboard types. Even if you handle what a type should be in your app, KeyboardKit helps you handling this. If you only use a single keyboard in your app, you can ignore this altogether.
Thanks to @eduardoxlau, the demo also has an improved emoji keyboard.
KeyboardAction
has new standardTap/DoubleTap/LongPress/Repeat
action properties.KeyboardInputViewController
has a new deviceOrientation
property.KeyboardInputViewController
has a new keyboardType
property.KeyboardInputViewController
has new can/changeKeyboardType
functions and properties.KeyboardInputViewController
has a new setupKeyboard
function.StandardKeyboardActionHandler
has more logic for handling keyboard type changes.EmojiCategory
enum represents the native iOS emoji keyboard categories.KeyboardStateInspector
can be implemented to get info about the keyboard.KeyboardAction.switchKeyboard
has been renamed to nextKeyboard
.KeyboardAction.switchToKeyboard
has been renamed to keyboardType
.KeyboardAction.standardInputViewControllerAction
has been renamed to standardTapAction
.KeyboardAction.standardTextDocumentProxyAction
is no longer used by the system`.addSwitchKeyboardGesture(to:)
has been renamed to addNextKeyboardGesture(to:)
.isKeyboardEnabled
has been replaced with a new KeyboardStateInspector
protocol.KeyboardType.alphabetic
now uses a KeyboardShiftState
property instead of a bool for if it's upper-cased or not.KeyboardAction.switchToKeyboard
is now an alias for keyboardType
. You can still use it when defining actions, but if you switch over KeyboardAction
, you have to use keyboardType
instead of switchToKeyboard
.This version fixes a gesture-related memory leak by no longer using the gesture extensions that caused the problem. Instead, KeyboardInputViewController
has a new set of internal gesture extensions that helps with adding gestures to a button.
This version also adds double-tap action handling to KeyboardKit. It's handled like taps, long presses and repeating actions, but it has no default logic. To handle it, create a custom action handler and override handle(_ gesture:,on action:, sender:)
.
KeyboardKit does not put any rules on the gesture handling. If you return an action for both a single tap and a double tap, both will be triggered.
.doubleTap
keyboard gesture.UIView
addLongPressAction
extension is deprecated.UIView
removeLongPressAction
extension is deprecated.UIView
addRepeatingAction
extension is deprecated.UIView
removeRepeatingAction
extension is deprecated.UIView
addTapAction
extension is deprecated.UIView
removeTapAction
extension is deprecated.