K3KeystrokeEngine

open class K3KeystrokeEngine(val model: K3Model, val multiTapTimeout: Duration = 200.milliseconds, val timeSource: TimeSource = TimeSource.Monotonic)(source)

The core keystroke engine for the k3lp library. This engine is responsible for handling raw key inputs, evaluating multi-tap behaviors, and mapping keystrokes to their respective outputs/actions based on the provided model.

New implementation specific actions can be added with the getActionForMarker function.

val customAction = getActionForMarker("namespace:customAction")

The namespace can be any valid alphanumerical custom string, e.g. example.

Constructors

Link copied to clipboard
constructor(model: K3Model, multiTapTimeout: Duration = 200.milliseconds, timeSource: TimeSource = TimeSource.Monotonic)

Creates a new instance of the K3 keystroke engine with the specified model and timing configurations.

Properties

Link copied to clipboard

The current inputContext.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val outputText: StateFlow<String>

StateFlow of the current output text.

Link copied to clipboard

Functions

Link copied to clipboard
protected fun descriptorOf(qualifiedName: String): K3Descriptor?

Obtain the K3Descriptor for the given qualified name.

Link copied to clipboard

Processes a given K3String or K3Descriptor. If the value is a string, this function behaves as if emitText was directly invoked. If the value is a descriptor, the namespaced descriptor processor (if any) will be invoked.

Link copied to clipboard

Performs a backspace action by first doing a backspace transform pass, followed by a simple transform pass.

Link copied to clipboard

Emits a descriptor by invoking the namespaced descriptor processor. May call other emit functions.

Link copied to clipboard

Emits \n by calling emitText.

Link copied to clipboard

Emits text to the end of the current input context, which is then potentially modified by transform rule matches.

Link copied to clipboard
fun onFlick(keyId: K3KeyId, flick: List<K3FlickDirection>)
Link copied to clipboard
open fun onKeyPress(key: K3Key): Boolean

Handles a key press for a specific K3Key.

Handles a key press event using the K3KeyId of a key.

Link copied to clipboard
open fun onLongPress(key: K3Key, index: Int): Boolean

Handle the longPressActions a K3Key has specified.

fun onLongPress(keyId: K3KeyId, index: Int): Boolean

Resolve the K3Key by keyId and perform onLongPress.

Link copied to clipboard
protected fun onProcessNamespacedDescriptor(namespace: String, processor: K3DescriptorProcessor<Boolean>)
Link copied to clipboard
fun reset(inputText: String)

Reset the current input context and discard all markers. Populate the input context with the new inputText.