Releases: Loop312/compose-keyhandler
Releases · Loop312/compose-keyhandler
v1.0.1
✨ New Features
KeyHandlerHostcomposable now supports acontentAlignmentparameter to align the content it wraps.KeyHandlerHostcomposable now supports apropagateMinConstraintsparameter to determine whether incoming minimum constraints from the parent are passed to its content
v1.0.0
This release marks a complete internal and external refactor of the key handling mechanism. The new architecture is more expressive, thread-safe, and designed specifically for Compose Multiplatform.
💥 Breaking Changes
- Refactored Key Mapping API: All single action and continuous action properties (
keys,singleActionKeys,combinations, etc.) have been removed. Key mappings are now grouped by a singleTriggertype. - New DSL Initialization: Key mapping is now done via a Type-Safe Builder (DSL) structure using functions like
onPress { key(...) }andonRelease { combo(...) } }. The oldaddKey/addCombinationmethods are deprecated/removed. - Continuous Handling Method Changed: The old
loopBasedHandling: Booleanflag andhandleInLoop()method have been removed. Continuous actions are now handled using two distinct, modern triggers:ON_REPEAT: Uses the system's native key repeat events (handled inlisten).ON_HOLD: Uses a dedicated, cancellable coroutine loop (handled viaKeyHandlerHost).
- Required Composable Wrapper: To use
ON_HOLDactions safely, all usage must now be wrapped in theKeyHandlerHostcomposable, which manages focus and the background coroutine lifecycle.
✨ New Features
-
Type-Safe DSL for Key Mapping: Introduced a clean, keyword-like API for defining key and combination actions:
onPress,onRelease,onHold, andonRepeat. -
Composable Lifecycle Management: Introduced
KeyHandlerHostto manage focus and safely launch the continuousON_HOLDcoroutine loop. This ensures thread safety and prevents resource leaks when the component leaves the composition. -
Hold Trigger Frequency: Added
holdTriggerFrequency: Intto control the execution rate ($\text{Hz}$ ) ofON_HOLDactions. -
Flexible Combo Definition: The
combofunction in the DSL can accept up to 4 keys for a combination (e.g.,combo(Key.Ctrl, Key.Shift, Key.A, Key.B) { ... }). -
Improved
toString()Output: TheKeyHandler.toString()method now displays actions clearly grouped by theirTriggertype.
🐛 Bug Fixes and Improvements
- Multiplatform Safety: The continuous loop for held keys is now a suspending function (
startHoldLoop) and is tied to the Compose Coroutine Scope, making the library reliably safe for Kotlin Multiplatform (KMP) usage.
What's Changed
Full Changelog: v0.7.0...v1.0.0
v0.7.0
Full Changelog: v0.6.1...v0.7.0
- added option for true continuous key handling
v0.6.1
Full Changelog: v0.6.0...v0.6.1
- Can now Initialize key binds straight from constructor
v0.6.0
Full Changelog: v0.5.0...v0.6.0
- added ability to bind multiple keys to one action in one go
- added descriptions to keys
-- added ability to get descriptions based on keys or combinations
-- updated toString to include descriptions
v0.5.0
Full Changelog: 0.5.0...v0.5.0