# keyborg

> Keyboard Navigation Detection for Web

Latest version **3.498.0** (published 2026-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install keyborg
pnpm add keyborg
yarn add keyborg
bun add keyborg
```

## Health

**Score 70/100 (B)** — status: active.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.498.0 |
| Published | 2026-09-03 |
| First published | 2021-05-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 85.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Marat Abdullin |
| Maintainers | uifabricteam, microsoft1es, microsoft-oss-releases |

## Links

- npm: https://www.npmjs.com/package/keyborg
- Repository: https://github.com/microsoft/keyborg
- Homepage: https://github.com/microsoft/keyborg#readme
- Issues: https://github.com/microsoft/keyborg/issues
- npm.io page: https://npm.io/package/keyborg

## Recent versions

- 3.498.0 (latest) — 2026-09-03
- 3.728.0-canary.0 (canary) — 2026-06-12
- 1.1.0-alpha.4 (alpha) — 2021-12-07
- 3.727.0-canary.0 — 2026-06-12
- 3.726.0-canary.0 — 2026-06-12
- 3.725.0-canary.0 — 2026-06-12
- 3.724.0-canary.0 — 2026-06-12
- 3.723.0-canary.0 — 2026-06-12
- 3.722.0-canary.0 — 2026-06-12
- 3.721.0-canary.0 — 2026-06-12
- 3.720.0-canary.0 — 2026-06-12
- 3.719.0-canary.0 — 2026-06-12
- 3.718.0-canary.0 — 2026-06-12
- 3.717.0-canary.0 — 2026-06-12
- 3.716.0-canary.0 — 2026-06-12
- … 1074 more at https://npm.io/package/keyborg/versions

## README

# Keyborg ⌨️🤖

Keyborg is a library that tracks the state of current keyboard input on a web page through focus events.

**It does not do anything invasive to the DOM** but provides an event subscription system that allows users to choose how they want to react to changes in focus.

## Getting started

### Installation

```bash
# NPM
npm install --save keyborg
# Yarn
yarn add keyborg
```

### Usage

```js
import { createKeyborg } from "keyborg";

// initializes keyborg on the current window
const keyborg = createKeyborg(window);

// This is called every time the keyboard input state changes
const handler = (isUsingKeyboard) => {
  if (isUsingKeyboard) {
    document.body.setAttribute("data-is-keyboard", "true");
  } else {
    document.body.removeAttribute("data-is-keyboard");
  }
};

keyborg.subscribe(handler);
keyborg.unsubscribe(handler);
```

## Contributing

Pretty simple currently, you only need to know about theese commands

- `npm install` - install dependencies
- `npm run build` - builds the library
- `npm run format:fix` - runs prettier to format code
- `npm run lint:fix` - runs eslint and fixes issues

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

## Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.

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