# makeup-typeahead

> Captures character keys pressed and returns a list of relevant strings

Latest version **0.4.0** (published 2026-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install makeup-typeahead
pnpm add makeup-typeahead
yarn add makeup-typeahead
bun add makeup-typeahead
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2026-03-31 |
| First published | 2020-11-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 47 |
| Author | Austin Gardner |
| Maintainers | dylanpiercey, sendlo, ianmcburnie, agliga, saiponnada, artblue, lulavalva |
| Keywords | makeup, ebay, accessibility, a11y |

## Links

- npm: https://www.npmjs.com/package/makeup-typeahead
- Repository: https://github.com/makeup/makeup-js.git#master
- Homepage: https://github.com/makeup/makeup-js/tree/master#readme
- Issues: https://github.com/makeup/makeup-js/issues
- npm.io page: https://npm.io/package/makeup-typeahead

## Recent versions

- 0.4.0 (latest) — 2026-03-31
- 0.3.5 — 2026-01-21
- 0.3.3 — 2024-12-20
- 0.3.2 — 2024-11-22
- 0.3.1 — 2024-09-03
- 0.3.0 — 2024-06-23
- 0.2.2 — 2024-06-17
- 0.2.1 — 2022-11-26
- 0.2.0 — 2022-02-02
- 0.1.0 — 2021-07-10
- 0.0.2 — 2020-11-30
- 0.0.1 — 2020-11-19

## README

# makeup-typeahead

This module produces a function generator. The generated function produces the index of the suggested menu item to highlight / focus. It keeps track of the characters entered, adding them onto a string.

Its parameters are a list of DOM nodes, a char, and the length of a timeout. Each character starts a new timeout. These timeouts are stacked, not debounced — when a timeout fires it resets the accumulated string regardless of subsequent keypresses.

When the timeout executes the callback, it will re-start the suggestions with an empty string.

## Experimental

This module is still in an experimental state, until it reaches v1 you must consider all minor releases as breaking changes.

### Example

```js
import typeahead from "makeup-typeahead";

const list = document.querySelector("ul");
const selected = document.querySelector(".selected");
const TIMEOUT_LENGTH = 2000;

const { getIndex, destroy } = typeahead();

function handleKeyDown(e) {
  if (e.key.length === 1) {
    const listIndex = getIndex(list.children, e.key, TIMEOUT_LENGTH);
    if (listIndex !== -1) {
      selected.innerHTML = list.children[listIndex].innerHTML;
    }
  }
}
```

---
_Source: https://npm.io/package/makeup-typeahead · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
