Files
bsky-social-app/src/components/hooks/useOnKeyboard.ts
T
2026-03-09 22:53:32 +02:00

20 lines
387 B
TypeScript

import {useEffect} from 'react'
import {
Keyboard,
type KeyboardEventListener,
type KeyboardEventName,
} from 'react-native'
export function useOnKeyboard(
eventName: KeyboardEventName,
cb: KeyboardEventListener,
) {
useEffect(() => {
const subscription = Keyboard.addListener(eventName, cb)
return () => {
subscription.remove()
}
}, [eventName, cb])
}