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

@asphalt-react/keypad

v2.16.0

Published

Keypad component for numeric and arithmetic input.

Downloads

169

Readme

Keypad

npm npm version

Keypad renders an on-screen grid of numeric and arithmetic keys for use cases like PIN entry, OTP entry, amount entry, and POS-style flows. It supports two layouts — numeric only (3 × 4) and numeric with arithmetic operators (4 × 4).

Keypad is headless — it renders keys and emits key activations, but does not render a display or own any value state. Consumers compose Keypad with @asphalt-react/textfield's Input, or any other display, and own the value buffer and arithmetic logic themselves.

Usage

import { useState } from "react"
import { Keypad } from "@asphalt-react/keypad"
import { Input } from "@asphalt-react/textfield"

const Example = () => {
  const [value, setValue] = useState("")

  const handleKeyPress = (key) => {
    if (key === "delete") {
      setValue((v) => v.slice(0, -1))
      return
    }
    if (key === "clear") {
      setValue("")
      return
    }
    setValue((v) => v + key)
  }

  return (
    <>
      <Input value={value} readOnly aria-label="Keypad output" />
      <Keypad onKeyPress={handleKeyPress} />
    </>
  )
}

Layout

Keypad renders 2 variants:

  • With operator keys (default): a 4 × 4 grid with ÷ × − + as the fourth column.
  • Without operator keys: a 3 × 4 grid. Set operatorKeys to false.

Key values

| Category | Emitted values | | --------- | ----------------------------------------------- | | Digits | "0""9", "000" | | Operators | "add", "subtract", "multiply", "divide" | | Actions | "delete", "clear" |

Digits are emitted as character literals so they can be appended to a string buffer directly. Operators and actions are emitted as semantic identifiers, decoupled from their rendered glyphs (×, ÷, ) and from physical-keyboard symbols (* / -).

"000" is a multi-character digit; if you check key.length === 1 to detect a digit, account for it.

Delete and clear

A short press or click on the delete key emits "delete". Press and hold the delete key (pointer or touch, ≥ 500ms) to emit "clear" instead, letting a single key clear the entire value. Long-press is pointer/touch only — keyboard users press delete repeatedly for repeated deletes.

Accessibility

  • Navigate among keys using arrow keys. Left/right move by one key; up/down move by a row.
  • Only the active key is in the tab order (roving tabindex) — tab moves focus into and out of the Keypad in one step.
  • Activate the focused key with enter or space.
  • Digits 09 and operators + - * / on a physical keyboard are emitted directly, regardless of which key currently has focus, so long as a key inside the Keypad is focused.
  • Operator keys carry accessible labels distinct from their visible content.

iOS WKWebView

Keypad uses a native (non-React) event listener for pointer/touch activation, rather than React's onClick/onPointerDown. This avoids a WKWebView-specific bug where rapid taps get lost because React's delegated events fire too late to stop the WebView's native blur behaviour. This only matters when Keypad is bound to an external, separately-focused input; Keypad's own internal focus handling is unaffected.

Props

onKeyPress

Callback to handle key activation.

The function accepts 1 argument:

  • value: a digit ("0"-"9", "000"), an operator ("add"/ "subtract"/"multiply"/"divide"), or "delete"/"clear".
onKeyPress(value) {
 console.log(value)
}

| type | required | default | | ---- | -------- | ------- | | func | false | null |

operatorKeys

Renders the arithmetic operator column (÷ × − +) when true.

| type | required | default | | ---- | -------- | ------- | | bool | false | true |