I am trying to create an icon button which invokes a lambda when tapped, but if the user presses the button and holds it, then also the lambda should get continuously invoked in fixed intervals.
@Composable
fun MyIconButton(
someLambda: () -> Unit
) {
IconButton(onClick = someLambda) {
Icon(
// painter and content description
)
}
}
Here what I want is that when user presses the button, someLambda
should get invoked (which is working fine). Additionally, I also want to invoke someLambda
repeatedly (with a gap of 500ms between two invocations) until the user releases the button.
Basically what I want is to detect something like the KeyUp and KeyDown events.
How to achieve this?