@@ -76,6 +76,9 @@ import com.dessalines.thumbkey.utils.toPx
7676import kotlin.math.abs
7777import kotlin.math.max
7878import kotlin.math.min
79+ import kotlin.time.Duration.Companion.seconds
80+ import kotlin.time.TimeMark
81+ import kotlin.time.TimeSource
7982
8083@OptIn(ExperimentalFoundationApi ::class )
8184@Composable
@@ -85,7 +88,7 @@ fun KeyboardKey(
8588 // key will attempt to capture it instead. This is derived automatically from the keyboard
8689 // layout, and should not be set directly in the keyboard definition.
8790 ghostKey : KeyItemC ? = null,
88- lastAction : MutableState <KeyAction ?>,
91+ lastAction : MutableState <Pair < KeyAction , TimeMark > ? >,
8992 animationHelperSpeed : Int ,
9093 animationSpeed : Int ,
9194 autoCapitalize : Boolean ,
@@ -210,14 +213,14 @@ fun KeyboardKey(
210213 onClick = {
211214 // Set the last key info, and the tap count
212215 val cAction = key.center.action
213- lastAction.value?.let { lastAction ->
214- if (lastAction == cAction && ! ime.didCursorMove()) {
216+ lastAction.value?.let { ( lastAction, time) ->
217+ if (time.elapsedNow() < 1 .seconds && lastAction == cAction && ! ime.didCursorMove()) {
215218 tapCount + = 1
216219 } else {
217220 tapCount = 0
218221 }
219222 }
220- lastAction.value = cAction
223+ lastAction.value = Pair ( cAction, TimeSource . Monotonic .markNow())
221224
222225 // Set the correct action
223226 val action = tapActions[tapCount % tapActions.size]
@@ -562,7 +565,7 @@ fun KeyboardKey(
562565
563566 // Set tapCount and lastAction to avoid issues with multitap after slide
564567 tapCount = 0
565- lastAction.value = action
568+ lastAction.value = Pair ( action, TimeSource . Monotonic .markNow())
566569
567570 // Reset the drags
568571 offsetX = 0f
0 commit comments