1.0.4 • Published 3 years ago
use-keyboard-state v1.0.4
Use keyboard state
This is a custom hook that helps you detect if the virtual keyboard is open on mobile devices. It also gives you the keyboard height to change your styles accordingly.
Installation
npm install use-keyboard-state
// or
yarn add use-keyboard-stateUsage
Import the package:
import useKeyboardState from 'use-keyboard-state';And inside your component you can use it simply by
const [isKeyboardOpen, keyboardHeight] = useKeyboardState();isKeyboardOpenis aBooleanthat toggles whenever user focuses on an input elementkeyboardHeightis anumbervalue that returns the height of the keyboard.