CleverKeys Technical Specifications
Technical documentation for CleverKeys, an Android keyboard with neural swipe typing. These specs are designed for LLM coding agents to understand the codebase architecture and implementation details.
File
Purpose
CleverKeysService.kt
Main InputMethodService
Keyboard2View.kt
Custom view rendering
Keyboard2.kt
Key layout and state management
KeyEventHandler.kt
Key press processing
InputConnectionManager.kt
Text editing interface
Pointers.kt
Touch handling and gestures
Config.kt
All settings with defaults
SettingsActivity.kt
Settings UI (Jetpack Compose)
KeyValue.kt
Key definitions (300+ keys)
SwipeTrajectoryProcessor.kt
Neural swipe processing
OptimizedVocabulary.kt
Dictionary management
┌─────────────────────────────────────────────────────────────┐
│ CleverKeysService │
│ (InputMethodService) │
├─────────────────────────────────────────────────────────────┤
│ ┌────────────────┐ ┌────────────────┐ ┌──────────────┐ │
│ │ Keyboard2View │ │ KeyEventHandler│ │ InputConnection│ │
│ │ (Rendering) │ │ (Processing) │ │ Manager │ │
│ └───────┬────────┘ └───────┬────────┘ └──────┬───────┘ │
│ │ │ │ │
│ ┌───────▼────────┐ ┌───────▼────────┐ │ │
│ │ Keyboard2 │ │ Pointers │ │ │
│ │ (Layout/State) │ │ (Touch/Gesture)│ │ │
│ └───────┬────────┘ └───────┬────────┘ │ │
│ │ │ │ │
│ ┌───────▼───────────────────▼───────────────────▼───────┐ │
│ │ Config │ │
│ │ (Settings, Preferences) │ │
│ └────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ Neural Prediction Pipeline │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Swipe │ │ ONNX │ │ Vocabulary │ │
│ │ Trajectory │→ │ Inference │→ │ Filter │ │
│ │ Processor │ │ (Encoder/ │ │ (Dictionary) │ │
│ │ │ │ Decoder) │ │ │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────┘
// Read setting
val value = Config .globalConfig().settingName
// Save setting
Config .globalConfig().apply {
settingName = newValue
saveSetting(" setting_key" , newValue)
}
// In KeyEventHandler
fun handleKeyPress (key : KeyValue ): Boolean {
return when (key.kind) {
Kind .Char -> commitText(key.char.toString())
Kind .String -> commitText(key.string)
Kind .Modifier -> handleModifier(key)
Kind .Event -> handleEvent(key.event)
// ... other kinds
}
}
// In Pointers.kt
fun classifyGesture (pointer : Pointer ): GestureType {
return when {
pointer.isSwipeTyping -> GestureType .SWIPE_TYPING
pointer.isShortSwipe -> GestureType .SHORT_SWIPE
pointer.isLongPress -> GestureType .LONG_PRESS
else -> GestureType .TAP
}
}