A high-performance, zero-dependency, pure JavaScript keyboard utility for React Native and Expo. No native modules, no complex setup, just smooth keyboard handling.
- Zero Native Modules: Works in Expo Go without
prebuild. - Smart Resizing: Automatically detects Android's
adjustResizeto prevent "Double Spacing" glitches. - Performant: Uses optimized listeners and Animated API.
- Simple API: Easy-to-use hooks and components.
- Cross-Platform: Consistent behavior across iOS and Android.
npm install react-native-pure-keyboard
# or
yarn add react-native-pure-keyboardTrack keyboard state anywhere in your app.
import { useKeyboard } from 'react-native-pure-keyboard';
const MyComponent = () => {
const { keyboardHeight, isKeyboardVisible } = useKeyboard();
return (
<View>
<Text>Keyboard is {isKeyboardVisible ? 'Visible' : 'Hidden'}</Text>
<Text>Height: {keyboardHeight}px</Text>
</View>
);
};The easiest way to avoid the keyboard. Just drop it at the bottom of your screen.
import { KeyboardSpacer } from 'react-native-pure-keyboard';
const LoginScreen = () => {
return (
<View style={{ flex: 1 }}>
<ScrollView>
{/* Your inputs here */}
</ScrollView>
{/* Expands on iOS, Smart-resizes on Android */}
<KeyboardSpacer />
</View>
);
};Returns an object with:
keyboardHeight: (number) The current height of the keyboard in pixels.isKeyboardVisible: (boolean) True if the keyboard is active.keyboardDuration: (number) The animation duration (ms).
Props:
style: (ViewStyle) Custom styles for the spacer.offset: (number) Extra padding (default:0).- Smart Behavior: On Android, this component automatically stays at
0height if your app is inadjustResizemode (default for Expo), preventing common layout glitches.
This project is licensed under the Apache-2.0 License.