npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-mobile-keyboard-opener

v2.0.1

Published

React hook and component to focus an input and trigger the mobile on-screen keyboard (iOS Safari, Android Chrome) from a click on another element.

Readme

React Mobile Keyboard Opener

A React hook and component to focus an input and trigger the on-screen keyboard on mobile web pages, even when the input you want focused isn't the element the user actually tapped.

iOS Safari and other mobile browsers only pop the soft keyboard when focus() happens synchronously inside a real user-interaction event handler (e.g. click) — calling it after an await or inside a callback won't work. This library wires that up for you: attach a listener to one element (helperId), and it focuses another element (targetId) inside that same handler.

Install

npm install react-mobile-keyboard-opener
# or
yarn add react-mobile-keyboard-opener

Peer dependency: react / react-dom 17, 18, or 19.

Usage

Hook

Use the hook when you already have a visible input you want to focus.

import useMobileKeyboardOpener from 'react-mobile-keyboard-opener';

function Example() {
  useMobileKeyboardOpener({
    helperId: 'open-search', // element the user taps
    targetId: 'search-input', // element to focus
  });

  return (
    <>
      <button id="open-search">Search</button>
      <input id="search-input" />
    </>
  );
}

Component

Use MobileKeyboardOpener when you don't have an input to focus at all — it renders a hidden one for you and focuses that.

import { MobileKeyboardOpener } from 'react-mobile-keyboard-opener';

function Example() {
  return (
    <>
      <button id="open-search">Search</button>
      <MobileKeyboardOpener
        helperId="open-search"
        callback={() => console.log('keyboard opened')}
      />
    </>
  );
}

Options

| Option | Type | Default | Description | | --- | --- | --- | --- | | helperId | string | (required) | id of the element the user interacts with | | targetId | string | (required for the hook; component falls back to its own hidden input) | id of the element to focus. If you pass this to MobileKeyboardOpener, it renders nothing — you already have an element to focus, so there's no hidden input to add | | event | keyof HTMLElementEventMap | 'click' | event on helperId that triggers focusing — must be a real user interaction for mobile browsers to allow the keyboard to open | | enabled | (e: Event) => boolean | () => true | return false to skip focusing for this particular event | | callback | () => void | () => null | called after the target has been focused | | preventScroll | boolean | false | passed through to target.focus({ preventScroll }) | | focusOnInit | boolean | false | hook only — focus targetId once on mount, without waiting for helperId |

MobileKeyboardOpener additionally accepts inputProps (React.InputHTMLAttributes<HTMLInputElement>), forwarded to the hidden <input> it renders when targetId is omitted. If inputProps.id is set, it's used as the fallback targetId; otherwise the fallback is hidden_input. inputProps is ignored when targetId is provided, since no hidden input gets rendered in that case.

Development

yarn install
yarn watch   # rollup in watch mode + a local static server for src/iife.tsx
yarn build   # emit dist/cjs, dist/esm, dist/iife, dist/index.d.ts
yarn lint

License

MIT © Howard Tang