Skip to content

Releases: Loop312/compose-keyhandler

v1.0.1

21 Oct 04:23

Choose a tag to compare

✨ New Features

  • KeyHandlerHost composable now supports a contentAlignment parameter to align the content it wraps.
  • KeyHandlerHost composable now supports a propagateMinConstraints parameter to determine whether incoming minimum constraints from the parent are passed to its content

v1.0.0

29 Sep 03:11
59266ef

Choose a tag to compare

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 single Trigger type.
  • New DSL Initialization: Key mapping is now done via a Type-Safe Builder (DSL) structure using functions like onPress { key(...) } and onRelease { combo(...) } }. The old addKey/addCombination methods are deprecated/removed.
  • Continuous Handling Method Changed: The old loopBasedHandling: Boolean flag and handleInLoop() 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 in listen).
    • ON_HOLD: Uses a dedicated, cancellable coroutine loop (handled via KeyHandlerHost).
  • Required Composable Wrapper: To use ON_HOLD actions safely, all usage must now be wrapped in the KeyHandlerHost composable, 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, and onRepeat.
  • Composable Lifecycle Management: Introduced KeyHandlerHost to manage focus and safely launch the continuous ON_HOLD coroutine loop. This ensures thread safety and prevents resource leaks when the component leaves the composition.
  • Hold Trigger Frequency: Added holdTriggerFrequency: Int to control the execution rate ($\text{Hz}$) of ON_HOLD actions.
  • Flexible Combo Definition: The combo function 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: The KeyHandler.toString() method now displays actions clearly grouped by their Trigger type.

🐛 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

16 Aug 19:58

Choose a tag to compare

Full Changelog: v0.6.1...v0.7.0

  • added option for true continuous key handling

v0.6.1

24 Jul 17:58

Choose a tag to compare

Full Changelog: v0.6.0...v0.6.1

  • Can now Initialize key binds straight from constructor

v0.6.0

22 Jul 20:24

Choose a tag to compare

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

16 Jul 22:21

Choose a tag to compare

Full Changelog: 0.5.0...v0.5.0

v0.5.0

16 Jul 22:02

Choose a tag to compare

What's Changed

  • minor README.md fix by @Loop312 in #4
  • added more options for key handling
  • updated dependencies

Full Changelog: 0.2.1...0.5.0

0.2.1

22 Feb 18:29
d9abb20

Choose a tag to compare

What's Changed

Full Changelog: 0.2.0...0.2.1

0.2.0

22 Feb 03:21
e6a9dd8

Choose a tag to compare

What's Changed

Full Changelog: 0.0.2...0.2.0

0.0.2

22 Feb 03:14
2dfe250

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 0.1.4...0.0.2