KeyboardConfiguration

Initial setup of the keyboard.

This class has all the different configurations of the keyboard.

Constructor:

  public init(dataCapture: FleksyKeyboardSDK.DataCaptureMode = .disabled, 
              style: StyleConfiguration = .init(), 
              typing: TypingConfiguration = .init(), 
              specialKeys: SpecialKeysConfiguration? = nil, 
              apps: FleksyKeyboardSDK.AppsConfiguration = .init(), 
              customLayout: FleksyKeyboardSDK.CustomLayoutConfiguration = .init(),
              license: LicenseConfiguration, 
              debug: DebugConfiguration = .init())

This call is called when the KeyboardViewController starts up.

Example:

    override func createConfiguration() -> KeyboardConfiguration {
        // Configuration of the keyboard
     
        // Style
        let style = StyleConfiguration()
        
        // TypingConfiguration which includes punctuationSymbols
        let typing = TypingConfiguration()
      
        // LicenseConfiguration for the valdity of the license.
        let license = LicenseConfiguration(licenseKey: <licenseKey>, licenseSecret: <licenseSecret>)

        // KEYBOARD CONFIGURATION --
        // it groups capture, style and takes as constructor if we want a custom view or not + specific height
        //
        let config = KeyboardConfiguration(style: style,
                                         typing: typing,
                                         license: license)
        return config
    }

Summary

Event Description
licenseConfiguration Configuration for the license key.
styleConfiguration Configuration for the style of the keyboard - themes.
emojiConfiguration Configuration for the emojis.
typingConfiguration Configuration for the typing.
feedbackConfiguration Configuration for the feedback to the end-user.
dataCaptureMode Configuration for data capture.
appsConfiguration Configuration for apps, also called plugins, to be shown in the keyboard.
specialConfiguration Configuration for special keys in the keyboard.
customLayoutConfiguration Configuration for custom action on the layout.
debugConfiguration Configuration for enabling more elements for debug.

LicenseConfiguration

Class to configure the licenseKey and the licenseSecret for the keyboard.

@property (copy, nonatomic, nullable) NSString *licenseSecret;

- (instancetype)initWithLicenseKey:(nonnull NSString *)licenseKey
                     licenseSecret:(nonnull NSString *)licenseSecret;

@end

Example:

let license = LicenseConfiguration(licenseKey: <licenseKey>, licenseSecret: <licenseSecret>)

Notes:

  • licenseKey and licenseSecret are provided by Fleksy.

StyleConfiguration

Class to configure the look and feel of the keyboard SDK at startup time.

By default we have one light and dark theme. If you want to change it, initiate this with the specific theme to load.

Constructor:

    public convenience init(keyboardSize: FleksyKeyboardSDK.StyleConfiguration.KeyboardSize = .original, 
        keyboardFont: FleksyKeyboardSDK.StyleConfiguration.KeyboardFont = FleksyLegacySettings.getKeyboardFont() ?? .system(),
         spacebarLogoImage: @autoclosure @escaping () -> UIImage? = nil, 
         spacebarStyle: enumSpacebarStyle = .spacebarStyle_Automatic, 
         spacebarLogoContentMode: UIView.ContentMode = .center)

Parameters:

Class Properties:


    final public let keyboardFont: FleksyKeyboardSDK.StyleConfiguration.KeyboardFont

    final public var spacebarLogoImage: UIImage? { get }
    final public var spacebarLogoContentMode: UIView.ContentMode { get }
    final public var spacebarStyle: enumSpacebarStyle
    
    final public var dictForceTheme: [String : Any]
    final public var dictForceDarkTheme: [String : Any]
Property Description
keyboardFont Property to customise the font of the keyboard keys. By default we use the system one.
spacebarLogoImage UIImage to be rendered on the spacebar.
spacebarLogoContentMode UIView.ContentMode for placing the image properly.
spacebarStyle SpacebarStyle.Automatic: Shows user languages when more than one configured.
SpacebarStyle.LogoOnly: Shows logo always
SpacebarStyle.LanguageOnly: Shows only the user languages when more than one configured, regardless of whether a logo has been set.
dictForceTheme KeyboardTheme that will shape the look and feel of the keyboard when the light mode is required.
dictForceDarkTheme KeyboardTheme that will shape the look and feel of the keyboard when the dark mode is required.

By default, those are <nil>. If you initialise them, a logo in the space bar will appear.

KeyboardFont

Enum Description
system System font and weight .regular is used.
custom Your own custom font. Important: Remember that you must bundle the custom font file into your keyboard extension target.

KeyboardTheme

Initialises and returns a new keyboard theme object with the specified parameters

Parameters Description
key The key identifier of the theme
name The name of the theme
backgroundGradient Color array of the keyboard background gradient, the first color is assigned to the main background color
image The name of the background image file from the bundle with extension
imageAlpha The alpha of the background image. Values between 0 and 1
imagePosition The scaling of the background image
keyLetters The color of the letters on the keys
keyBackground The key caps background color
keyShadow The shadow color for the key caps
hoverLetters The text color of the hover when hovering a key
hoverBackground The background color of the hover when hovering a key
hoverSelectedLetters The text color of the selected item while long-pressing on a multi-label key
hoverSelectedBackground The background color of the selected item while long-pressing on a multi-label key
suggestionLetters The text color of the non selected suggesions
suggestionBackground The background color of the suggestions strip
suggestionSelectedLetters The text color of the selected suggestion
suggestionSelectedBackground The background color of the selected suggestion
buttonLetters The color of the button keys
buttonBackground The background color of the button keys
buttonBackgroundPressed The background color of the button when pressed
buttonActionLetters The color of the action button
buttonActionBackground The background color of the action button
buttonActionBackgroundPressed The background color of the action button when pressed
buttonShiftLetters The color of the shift button
buttonShiftBackground The background color of the shift button
buttonShiftBackgroundPressed The background color of the shift button when pressed
buttonBackspaceLetters The color of the backspace button
buttonBackspaceBackground The background color of the backspace button
buttonBackspaceBackgroundPressed The background color of the spacebar when pressed
spacebarLetters The color of the spacebar
spacebarBackground The background color of the spacebar
spacebarBackgroundPressed The background color of the spacebar when pressed
homeBackground The background color of the middle row
swipeLine The color of the swipe line when swipe typing is enable
trackPadCursor The color of the cursor in the track pad
tileIcons The shapes of a key tile while hovering
extras Special keyboard behauvior and properties
sounds Sounds for keyboard gestures

EmojiConfiguration

Class to configure the look and feel of the emojis when the keyboard opens.

public init(recent: [String] = FleksyManagedSettings.recentEmojis, 
	defaultSkinTone: FleksyKeyboardSDK.EmojiConfiguration.EmojiSkinTone = FleksyLegacySettings.getDefaultEmojiSkinTone() ?? .neutral)

Properties

  • defaultSkinTone:
EmojiSkinTone Description
neutral Standard, by default. (E.g. 👋)
light Light emoji color. (E.g. 👋🏻)
mediumLight Medium Light emoji color. (E.g. 👋🏼)
medium Medium emoji color. (E.g. 👋🏽)
mediumDark Medium Dark emoji color. (E.g. 👋🏾)
dark Dark emoji color. (E.g. 👋🏿)
  • recent: Array of strings with the desired initial recent emojis. By default, Fleksy provides recent emojis.

  • emojiSearch: Ability to search emojis from the emoji screen. By default, this is enabled.

TypingConfiguration

Class to configure some of the aspects of the typing configuration.

/// Object used to configure the typing experience and features of the keyboard
public struct TypingConfiguration {

    public let caseSensitive: Bool

    public let smartPunctuation: Bool

    public let autoCorrect: Bool

    public let autoCorrectAfterPunctuation: Bool

    public let backspaceToUndoAutoCorrection: Bool

    public let autoCapitalization: Bool

    public let autoLearn: Bool

    public let doubleSpaceTapAddsPunctuation: Bool

    public let swipeTyping: Bool

    public let swipeTriggerLength: CGFloat

    public let swipeLeftToDelete: Bool

    public var punctuationSymbols: [String] { get }

    public var arrayPunctuationSymbols: [String]
    
    public let longPressShowsPunctuation: Bool

    public let keitaiEnabled: Bool

    public let keitaiDelay: TimeInterval

    public let spacebarMovesCursor: Bool

    public let useAllAccents: Bool

    public let magicButtonAction: FleksyKeyboardSDK.MagicButtonAction

    public var magicButtonLongPressActions: [FleksyKeyboardSDK.MagicButtonAction] { get }

    public let isMinimal: Bool

    public let numberRow: Bool
}
Name Value Default Description
caseSensitive Bool true It indicates whether the caps layout is automatically set after a punctuation symbol or at the start of an input field
smartPunctuation Bool false Spaces are added after punctuation
autoCorrect Bool true Enable or disable the autocorrect
autoCorrectAfterPunctuation Bool true A boolean indicating whether a word is autocorrected after a punctuation symbol is entered.
backspaceToUndoAutoCorrection Bool true Tapping the backspace key after an auto correction will undo the auto correction.
autoCapitalization Bool true Caps layout is automatically set after a punctuation symbol or at the start of an input field.
autoLearn Bool true Manually corrected words by the user are learned automatically
doubleSpaceTap-AddsPunctuation Bool true A punctuation symbol should be added after the user taps the spacebar twice
swipeTyping Bool true Swipe typing is enabled for dictionaries that support swipe typing
swipeTriggerLength CGFloat 30 The distance threshold to trigger the swipe typing gesture, measured in points. (we recommend to avoid modifying this value unless you know exactly your userbase)
swipeLeftToDelete Bool false A boolean indicating whether a swipe left gesture, which performs a word delete, is enabled or not. Important: If swipe typing is enabled, this swipe gesture cannot work. Therefore, the value of this property is affected by the value of swipeTyping. If swipeTyping is true, then swipeLeftToDelete is set to false regardless of the passed value at initialization.
punctuationSymbols / arrayPunctuation-Symbols [String] Empty Array of Strings. It holds the symbols that would appear when we do a long press on top of the “.“ next to the enter key.
longPressShowsPunctuation Bool false When true, holding on a key will show the numbers & symbols keyboard until the finger is released. Take into account that this would replace the functionality of long-pressing keys for accents. This can be useful when using minimal mode (isMinimal), where there’s no button to change to the numbers & symbols keyboard.
keitaiEnabled Bool true A boolean indicating whether keitai mode is enabled for the Japanese Flick keyboard
keitaiDelay TimeInterval - The amount of delay seconds for the Keitai rotations. Only considered when keitaiEnabled is true
spacebarMovesCursor Bool true It indicates whether the spacebar can move the cursor on a long press
useAllAccents Bool false When true, holding on a key will show all possible accents, and not only the common accents for the current language
magicButtonAction MagicButtonAction - The default action for the magic button of the keyboard (that is the special button on the left of the spacebar). It includes the emoji access, autocorrection toggle and comma. Default: .emoji
magicButtonLongPressActions MagicButtonAction - The array of available actions to show when the user long-presses the magic button. Default: [.emoji, .hideKeyboard, .autoCorrectToggle]
isMinimal Bool false A boolean indicating whether the bottom row of buttons is hidden (that is, the row containing the space bar, the enter button, etc.). Defaults to false. When set to true, you may want to use it in combination with longPressShowsPunctuation to allow users to access the numbers & symbols keyboard in minimal mode.
numberRow Bool false When true, for supported languages, a new row on top of the qwerty layout displays the numbers from 0 to 9.

FeedbackConfiguration

This class is used to configure the feedback that the user receives when interacting with the keyboard.

There are two main feedback elements:

  1. Sounds
  2. Haptic feedback
public struct FeedbackConfiguration : Equatable {

    public struct ResourceSoundSet : Equatable {

        /// The name of the sound file to play for different keys:
        public let tap: String
        public let button: String
        public let backspace: String

        /// Default SoundSet provided by Fleksy
        public static var defaultSoundSet: FleksyKeyboardSDK.FeedbackConfiguration.ResourceSoundSet { get }

        public init(tap: String, button: String? = nil, backspace: String? = nil)
    }

    public enum SoundMode : Equatable {
        case silent
        case sound(FleksyKeyboardSDK.FeedbackConfiguration.ResourceSoundSet = .defaultSoundSet)
    }

    public let soundMode: FleksyKeyboardSDK.FeedbackConfiguration.SoundMode

    public let haptics: Bool

    public init(soundMode: FleksyKeyboardSDK.FeedbackConfiguration.SoundMode = .silent, haptics: Bool = false)
}

Parameters:

FeedbackConfiguration

Property Value Default Description
soundMode Enum silent It receives a ResourceSoundSet to use it when the keyboard is not silent. By default sounds are disabled.
haptics Bool false Haptic feedback when a keyboard button is pressed. By default this is disabled.

ResourceSoundSet

Property Description
tap Sound that is triggered when the user presses any of keys, except the action buttons. Add a string with the name of the sound filename.
button Sound that is triggered when the user presses any of the action buttons except the delete button. Add a string with the name of the sound filename.
backspace Sound that is triggered when the user presses the backspace button. Add a string with the name of the sound filename.

Specification:

Sound files must be added in .caf or .wav file format.

DataCaptureMode

The data capture mode applied to the keyboard.

Notes:

  • Enable capturing requires an explicit consent from the user.
  • Enable logEvents only in internal or debug builds, to avoid leaking sensitive data to log files.
  • Using data capture mode requires a specific plan on the developer platform. (Check it here: Developer’s platform)

This class provides a way for the developer to capture the data produced by the user. There are three different types of data capture modes, mutually exclusive:

Disabled This is the default state. None of the data is captured.
Event based Data is captured on an event basis, which means that it is captured and delivered while it happens.
Session based Data is captured on a session basis. By session, we mean from the moment the end-user opens the keyboard until they hide the keyboard. After that period of time, the data is delivered.

Constructor:

/// An enum that defines the supported data capture modes by the SDK.
public enum DataCaptureMode {

    /// Data capture is disabled.
    case disabled

    /// Data capture is reported per-event in real time, i.e. data capture events are reported as soon as they happen.
    ///
    /// - Parameter configuration: The configuration defining the kind of events that should be reported. 
    ///                            Defaults to a EventDataConfiguration instance initialized with initialized with default parameters 
    ///
    case eventBased(configuration: FleksyKeyboardSDK.EventDataConfiguration = .init())

    /// Data capture is reported at the end of each keyboard session.
    /// - Parameter output: The type of output for the captured data. Defaults to enumCaptureOutput/captureOutput_file.
    /// - Parameter configuration: The specific configuration for the captured data. 
    ///                            
    /// - Parameter logEvents: A boolean indicating whether session-based data capture events should be logged. 
    ///                        Defaults to `false`
    case sessionBased(output: enumCaptureOutput = .captureOutput_file, configuration: FLDataConfiguration = .init(), logEvents: Bool = false)
}

Data Capture Disabled

Data capture is not enabled. This is the behaviour by default.

Example:

let capture = DataCaptureMode.disabled

Event-based Data Capture

When we enable the event-based data capture we need to set up two different items:

  1. Use the EventDataConfiguration to choose all the data that you would like to obtain.
  2. Set up the callback method to receive the data. Data will be received encapsulated in EventBasedDataCaptureEvent

Example Event-based

  /// Initial Configuration
  override func createConfiguration() -> KeyboardConfiguration {
      let eventDataConfiguration = EventDataConfiguration()
      let capture = DataCaptureMode.eventBased(configuration: eventDataConfiguration)
      [..]
      let config = KeyboardConfiguration(dataCapture: capture, ...)
      return config
   }
  
  [..]
  ///
  /// Override this method to start receiving the data preconfigured
  ///
  override func onDataCaptureEvent(_ event: EventBasedDataCaptureEvent) {
        #code#
    }

EventDataConfiguration

In order to select different types of data to be captured you should configure this class with your specific needs. By default, the constructuor captures all data except for keyPlane data.

Constructor


public init(keyStroke: Bool = true, 
            delete: Bool = true, 
            keyPlane: Bool = false, 
            word: Bool = true, 
            swipe: Bool = true, 
            sessionUpdate: Bool = true, 
            stressMonitor: Bool = true)

EventBasedDataCaptureEvent

Every time the system captures data it will deliver the data using this callback.

Example

    override func onDataCaptureEvent(_ event: EventBasedDataCaptureEvent) {
        #code#
    }

The enum EventBasedDataCaptureEvent holds different type of data as objects. All the different objects:

Parameter Data Class Description
sessionUpdate SessionUpdate The details regarding modifications to various session parameters are provided, encompassing information such as the timestamp, text field, language, and more.
keyStroke KeyStroke It contains all data related to a key stroke. From the time to press the key, position of the press, and the time and position of touching out the key.
word Word All typed words. It contains if the word was a prediction, an autocorrected word, and so on.
swipe Swipe All swiped words.
delete Delete It contains all data related to the delete action. Which type of character, character and so on.
keyPlane KeyPlane All the elements of the keyplane.
stressMonitor StressMonitor The stress capture.

(All the objects are common between platforms, same content on Android and iOS.)

Session Based Data Capture

When we enable the session-based data capture we want to receive data at the end of each session. In case that you want to process all the captured data outside of the keyboard this might be a good solution for you.

output enumCaptureOutput:
captureOutput_file : store data content in a file
captureOutput_string : send data at the end of the session via delegate function dataCollection
dataConfig The data capture configuration, see FLDataConfiguration
logEvents Parameter for debugging and seeing the events on the console.

Example:

  let dataConfig = FLDataConfiguration()
  let capture = DataCaptureMode.sessionBased(output: enumCaptureOutput.captureOutput_string, 
                                             configuration: dataConfig, 
                                             logEvents: false)

Fields:

Name Type Default value
output enumCaptureOutput captureOutput_file
dataConfiguration FLDataConfiguration FLDataConfiguration()
logEvents Boolean false

FLDataConfiguration

The data capture configuration.

Constructor:

public convenience init(
    text: Bool = true, 
    swipe: Bool = true, 
    emoji: Bool = true, 
    layout: Bool = true, 
    textField: Bool = true, 
    language: Bool = true, 
    type: Bool = true, 
    area: Bool = true, 
    code: Bool = true, 
    position: Bool = true,
    press: Bool = true, 
    keyPress: Bool = true, 
    keyCenter: Bool = true, 
    keyBounds: Bool = true, 
    configCoordinate: enumDataConfigCoordinate = .dataConfigCoordinate_screenPixel, 
    word: Bool = true, 
    delete: Bool = true, 
    keyPlane: Bool = true, 
    keyText: Bool = true, 
    positionEnd: Bool = true, 
    keyPressEnd: Bool = true, 
    predictionsTouch: Bool = true, 
    prediction: Bool = true, 
    configFormat: enumDataConfigFormat = .dataConfigFormat_standard, 
    accelerometer: Bool = false, 
    autocorrection: Bool = true, 
    distanceFromLastTouch: Bool = true, 
    keyPositionLimited: Bool = false, 
    autocorrectionLimited: Bool = false, 
    wordLimited: Bool = false, 
    predictionLimited: Bool = false, 
    swipeLimited: Bool = false, 
    deleteLimited: Bool = false, 
    stressMonitor: Bool = false,
    interKeyTimeHistogram: Bool = true, 
    interKeyTimeHistogramInterval: Int = 50, 
    interKeyTimeHistogramCount: Int = 21)
    
text Capture all the written text
swipe Capture all swipes of the user
emoji Capture all emojis with all hex values of them
layout Layout parameter: QWERTY, AZERTY, …
textField Field in which the user is typing. Specified in detail in the specs
language Capture the current language of the user
type Capture the type, which is a specific parameter
area Capture the area, which is another specific parameter
code Capture the code of the key pressed.
position Capture positions from the center of the key
press Capture the time of press and the time of release
keyPress Capture the press key in the coordinate system
keyCenter Capture the center key in the coordinate system
keyBounds Capture the bounds of the current key
configCoordinate The type of coordinate system to use.
See DataConfigCoordinate for the available options.
word Capture state and data of words
delete Capture words deleted
keyPlane Capture key planes
keyText Capture the labels of each key pressed
positionEnd Capture release positions from the center of the key
keyPressEnd Capture release positions
predictionsTouch Capture touch position of predictions
prediction Capture predictions selected
configFormat Format of data files. Can be any of:
dataConfigFormat_standard
dataConfigFormat_groupByTap
stressMonitor Provide information on the stress level of the person typing

DataConfigCoordinate

An object containing constants to different types of coordinate systems:

dataCaptureCoordinate_screenPixel Reference to all pixels of the whole screen. This includes all pixels regardless of the density.
dataCaptureCoordinate_keyboardPixel Reference to all pixels of the keyboard, but, with all the pixels, regardless of the density.
dataCaptureCoordinate_keyboard Reference to pixels of the keyboard, seen internally, which means that it would be different depending on the device, density, etc.
dataCaptureCoordinate_internalKeyboard Reference to the internal points for the Engine. 320 x 288 points

Note:

All the reported data are in the data capture for session which specifies all the different parameters.

AppsConfiguration

In progress

CustomLayoutConfiguration

Class to configure the custom layout for enabling a custom action.

public struct CustomLayoutConfiguration {

    public struct Button {

        /// Creates a new ``Button`` object.
        ///
        /// - Parameters:
        ///   - label: The case-insensitive label of the custom button. This string must match (case insensitively) the `label` of the custom button defined in `keyboard-global.json` file.
        ///   - image: The image to be shown in the custom button. If the ``image`` is `nil`, then the ``label`` will be shown and it will be shown in uppercase or lowercase depending of the state of the shift button.
        ///   - contentMode: The content mode for the ``image``. Ignored if ``image`` is `nil`.
        ///   - action: The action to perform when the user taps the custom button, containing the `label` of the tapped button.
        ///     - The closure receives the `label` of the tapped button, but only compare this `label` string parameter in a case-insentive manner, because when the current keyboard is uppercase, then the `label` parameter will be uppercased.
        public init(label: String, image: @autoclosure @escaping () -> UIImage?, contentMode: UIView.ContentMode = .center, action: @escaping (String) -> Void)
    }

    /// The name of the bundle file that needs to be used for the keyboard layout customization. **Do not include the ".bundle" extension** in the `bundleFileName` parameter. Defautls to `"fleksy-custom`.
    ///
    /// Passing an empty string or a name for a bundle file that does not exist has no layout customization effect.
    public let bundleFileName: String

    /// The array of custom `Button`s to define the look and behavior of the custom buttons declared in the bundle file
    ///
    /// If two buttons in the array have the same label (case insensitive) then only the first one in the array will be considered.
    public let buttons: [FleksyKeyboardSDK.CustomLayoutConfiguration.Button]

    /// Creates a new ``CustomLayoutConfiguration`` object.
    /// - Parameters:
    ///   - bundleFileName: The name of the bundle file that needs to be used for the keyboard layout customization. Passing an empty string or a name for a bundle file that does not exist has no layout customization effect.
    ///   - buttons: The array of custom `Button`s to define the look and behavior of the custom buttons declared in the bundle file. If two buttons in the array have the same label (case insensitive) then only the first one in the array will be considered.
    public init(bundleFileName: String = "fleksy-custom", buttons: [FleksyKeyboardSDK.CustomLayoutConfiguration.Button] = [])
   }

Parameters:

CustomLayoutConfiguration.Button:

  • label: The case-insensitive label of the custom button. This string must match (case insensitively) the label of the custom button defined in the bundleFileName. By default, the name of the label is custom-action.
  • image: The image to be shown in the custom button. If the image is nil, then the label will be shown and it will be shown in uppercase or lowercase depending of the state of the shift button.
  • contentMode: The content mode for the image. Ignored if image is nil.
  • action

CustomLayoutConfiguration:

  • bundleFileName: Name of the custom layout that you configure to enable a custom button on the layout. This is predefined, and you can get the custom-action layout from
  • buttons: Array of buttons related to the custom actions.

Example:

In order to implement a custom action on the layout, check the feature in detail: Custom Action

DebugConfiguration

Class to configure all related debugging aspects. This is not recommended to be used in a production environment.

@interface DebugConfiguration : NSObject

- (instancetype) initDebug;
@property (nonatomic) BOOL registerLayoutChange;
@end

Notes:

  • registerLayoutChange: Enabling this boolean enables the onLayoutChanges delegate.
  • In the case of initialise DebugConfiguration calling initDebug all flags will be set to “true“ in order to debug all related components.

If something needs to be added or if you find an error in our documentation, please let us know either on our GitHub or Discord.

Last updated on October 24, 2023