
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
bounce-keys
Advanced tools
Library to add support for the bounce keys accessibility feature on web elements like text input fields.
A JavaScript/TypeScript implementation of the Bounce Keys accessibility feature (see Wikipedia).
Inspired by the OS-level accessibility feature called Bounce Keys in GNOME and Chrome OS, and FilterKeys on Windows, this is a platform-agnostic implementation for the web.
bounce-keys is headless. It's unopinionated about design, and does not affect your design visually.
bounce-keys is primarily designed for developers who:
What bounce-keys can do, on a technical level:
keydown event listener to.What bounce-keys cannot or does not do:
If importing into a package built using Node, first import like this.
const { BounceKeys } = require("bounce-keys"); // From a CommonJS project
import { BounceKeys } from "bounce-keys"; // From an ES Modules project
See docs/ for a basic demo of a vanilla JS implementation.
JavaScript
// Can vary based on your development environment
import { BounceKeys } from "bounce-keys";
const bk = new BounceKeys({ bounceWindow: 750, repeatOnly: true });
const el = document.querySelector("input#my-text-box");
// keydown preferred, but any event that fires KeyboardEvent should work
el.addEventListener("keydown", bk);
HTML
<input type="text" id="my-text-box"/>
bounce-keys does not have idiomatic support for Svelte, but can be used via the use directive. Here's an example of basic usage on a single input, in TypeScript.
<script lang="ts">
import { BounceKeys } from "bounce-keys";
const bk = new BounceKeys({ bounceWindow: 750, repeatOnly: true });
function enableBounceKeys(inputEl: HTMLElement) { // HTMLElement type only required in TypeScript
inputEl.addEventListener("keydown", bk);
}
</script>
<input type="text" use:enableBounceKeys/>
bounce-keys does not have idiomatic support for React, but can be used via refs. Here's an example of basic usage on a single input.
import { BounceKeys } from "bounce-keys"
import { useRef } from "react";
function MyComponent() {
const bk = new BounceKeys({ bounceWindow: 750, repeatOnly: true });
const inputRef = useRef(null);
if (inputRef.current) {
inputRef.current.addEventListener("keydown", bk);
}
return (
<div className="my-component">
<input type="text" ref={inputRef}/>
</div>
);
}
Optionally, you can ask bounce-keys to emit events when keys are blocked, in case this is helpful to your application. One use would be to play custom audio cues.
Listen for the "bounce-keys:blocked" event on your input element. In vanilla JS/TS, this would look like:
const bk = new BounceKeys({ bounceWindow: 750, shouldEmitBlockEvents: true });
const el = document.querySelector("input#my-text-box");
el.addEventListener("keydown", bk);
el.addEventListener("bounce-keys:blocked", event => { doWhatYouWant(event); });
The event contains info about which keypress was blocked. Read it by accessing event.detail.code. Values will be string values of the code attribute in KeyboardEvents dispatched by the user's input.
bounce-keys supports up to four props, one of which is required.
| Prop | Type | Documentation |
|---|---|---|
bounceWindow | number | Time window in milliseconds to run the bounce check in. For ex. if set to 1000, the same key won't register if it was pressed in the last 1 second. The window is reset on each press. |
repeatOnly | boolean (optional) | If true, only successive repeats are blocked. For ex. typing "aaaaa" successively will register only one press, but typing "ababa" will register five times. |
shouldEmitBlockEvents | boolean (optional) | If true, emits a custom event "bounce-keys:blocked" when a key press is blocked. Useful for adding custom behavior like audio cues. |
ignoredKeyCodes | string[] | Set<string> (optional) | Array or set of key code strings that this library will ignore in its block logic. bounce-type relies on the code property of KeyboardEvents. See on MDN. |
FAQs
Library to add support for the bounce keys accessibility feature on web elements like text input fields.
We found that bounce-keys demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.