Skip to content

Commit 68fd468

Browse files
committed
update versions
1 parent 3257e02 commit 68fd468

File tree

4 files changed

+52
-36
lines changed

4 files changed

+52
-36
lines changed

README.md

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,63 @@ kotlin {
1313
//Format: groupId:artifactId:version
1414
//groupId = io.github.loop312
1515
//artifactId = compose-keyhandler
16-
//version = 0.2.1 (choose latest version instead)
17-
implementation("io.github.loop312:compose-keyhandler:0.2.1")
16+
//version = 0.5.0 (choose latest version instead)
17+
implementation("io.github.loop312:compose-keyhandler:0.5.0")
1818
}
1919
}
2020
}
2121
```
2222

2323
```kotlin
24-
implementation("io.github.loop312:compose-keyhandler:0.2.1")
24+
implementation("io.github.loop312:compose-keyhandler:0.5.0")
2525
```
2626

2727
### Common Main
2828
```kotlin
29+
//import io.github.loop312.compose_keyhandler.KeyHandler
2930
//import ...
30-
/*
31-
import io.github.loop312.compose_keyhandler.KeyHandler
32-
or for more fine control of the variables
33-
import io.github.compose_keyhandler.*
34-
*/
35-
36-
//doesn't need to be outside main function
37-
val keyHandler = KeyHandler()
38-
39-
keyHandler.addKey(Key.A){
40-
println("A is being pressed")
41-
//or any other action you want to do
42-
}
4331

4432
fun main() {
33+
//KeyHandler(false) will not consume key events
34+
val keyHandler = KeyHandler()
35+
36+
//continuous execution
37+
keyHandler.addKey(Key.A) {
38+
println("A is being pressed")
39+
//or any other action you want to do
40+
}
41+
42+
//one-time execution
43+
keyHandler.addSingleActionKey(Key.B) {
44+
println("B was pressed")
45+
//or any other action you want to do
46+
}
47+
48+
//on release execution
49+
keyHandler.addReleaseKey(Key.C) {
50+
println("C was released")
51+
//or any other action you want to do
52+
}
53+
54+
//continuous combination execution
55+
keyHandler.addCombination(setOf(Key.D, Key.E)) {
56+
println("DE is being pressed")
57+
//or any other action you want to do
58+
}
59+
60+
//one-time combination execution
61+
keyHandler.addSingleActionCombination(setOf(Key.F, Key.G)) {
62+
println("FG was pressed")
63+
//or any other action you want to do
64+
}
65+
//or Modifier.onPreviewKeyEvent(keyHandler.listen)
4566
Box(Modifier.onKeyEvent(keyHandler.listen)) {
4667
//...
4768
}
48-
keyHandler.activate()
4969
}
5070
```
5171

52-
## Method
53-
54-
- maps a key to an action
55-
- whenever a key is pressed, it gets added to a set
56-
- whenever a key is released, it gets removed from the set
57-
- while the key is pressed, the action is executed
58-
72+
### NOTE: Make sure object with modifier `onKeyEvent` or `onPreviewKeyEvent` is in focus
5973

6074
# Came With Project Structure
6175

compose-keyhandler/build.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ plugins {
1515
}
1616

1717
group = "io.github.loop312"
18-
version = "0.2.1"
18+
version = "0.5.0"
1919

2020
kotlin {
2121
androidTarget {
@@ -40,7 +40,7 @@ kotlin {
4040

4141
@OptIn(ExperimentalWasmDsl::class)
4242
wasmJs {
43-
moduleName = "composeApp"
43+
outputModuleName.set("composeApp")
4444
browser {
4545
val rootDirPath = project.rootDir.path
4646
val projectDirPath = project.projectDir.path
@@ -80,12 +80,13 @@ kotlin {
8080
implementation(compose.desktop.currentOs)
8181
implementation(libs.kotlinx.coroutines.swing)
8282
}
83-
83+
/*
8484
val commonTest by getting {
8585
dependencies {
8686
implementation(libs.kotlin.test)
8787
}
8888
}
89+
*/
8990
}
9091
}
9192

gradle/libs.versions.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[versions]
2-
agp = "8.5.2"
3-
kotlin = "2.1.0"
2+
agp = "8.10.1"
3+
kotlin = "2.2.0"
44
android-minSdk = "24"
5-
android-compileSdk = "34"
6-
compose-multiplatform = "1.7.3"
7-
androidx-lifecycle = "2.8.4"
8-
androidx-activityCompose = "1.10.0"
9-
kotlinx-coroutines = "1.10.1"
5+
android-compileSdk = "35"
6+
compose-multiplatform = "1.8.2"
7+
androidx-lifecycle = "2.9.1"
8+
androidx-activityCompose = "1.10.1"
9+
kotlinx-coroutines = "1.10.2"
1010

1111
[libraries]
12-
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
12+
#kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
1313
androidx-lifecycle-viewmodel = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-viewmodel", version.ref = "androidx-lifecycle" }
1414
androidx-lifecycle-runtime-compose = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidx-lifecycle" }
1515
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#Wed Jul 16 17:54:14 EDT 2025
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
45
networkTimeout=10000
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)