diff --git a/app/components/currency-keyboard/currency-keyboard.tsx b/app/components/currency-keyboard/currency-keyboard.tsx index 93136c858e..a2915b97e6 100644 --- a/app/components/currency-keyboard/currency-keyboard.tsx +++ b/app/components/currency-keyboard/currency-keyboard.tsx @@ -1,4 +1,4 @@ -import React from "react" +import React, { useEffect, useState } from "react" import { Pressable, StyleProp, View, ViewStyle } from "react-native" import { testProps } from "@app/utils/testProps" @@ -96,11 +96,39 @@ const Key = ({ return baseStyle } + const [timerId, setTimerId] = useState(null) + + const handleBackSpacePressIn = (numberPadKey: KeyType) => { + const id = setInterval(() => { + if (numberPadKey === KeyType.Backspace) { + handleKeyPress(numberPadKey) + } + }, 300) + setTimerId(id) + } + + const handleBackSpacePressOut = () => { + if (timerId) { + clearInterval(timerId) + setTimerId(null) + } + } + + useEffect(() => { + return () => { + if (timerId) { + clearInterval(timerId) + } + } + }, [timerId]) + return ( handleBackSpacePressIn(numberPadKey)} onPress={() => handleKeyPress(numberPadKey)} + onPressOut={handleBackSpacePressOut} {...testProps(`Key ${numberPadKey}`)} > {({ pressed }) => {