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

@kkeyboard/web

v0.3.15

Published

Framework-free browser controller and DOM component for KKeyboard

Readme

@kkeyboard/web

The web package exposes two layers:

  • createWebInputController: host-neutral keyboard behavior for a textarea, input, contenteditable adapter, or editor integration.
  • createWebInputComponent: a small framework-free DOM component that wires a host input to a caret-relative suggestion dropdown.
  • createContentEditableAdapter: a small host adapter for contenteditable editors, suitable for a WYSIWYG sample or a later Tiptap/ProseMirror wrapper.
  • getWebLocale: English and Khmer labels for host-controlled option panels and suggestion accessibility text.

The component keeps the engine independent from React, Svelte, Vue, rich-text editors, and native keyboard adapters. Those integrations can either use the controller directly or wrap the DOM component.

Component contract

import { createWebInputComponent } from "@kkeyboard/web";

const input = createWebInputComponent({
  editor: document.querySelector("#editor"),
  inputShell: document.querySelector(".input-shell"),
  editorCard: document.querySelector(".editor-card"),
  suggestionPopover: document.querySelector("#suggestion-popover"),
  candidatesElement: document.querySelector("#candidates"),
  navigationElement: document.querySelector("#candidate-navigation"),
  engine,
  boundary: " ",
  completionBoundary: "\u200b",
  getInputSettings: () => ({
    mode: "auto",
    register: "auto",
    completionEnabled: true,
    // Optional; next-word prediction is disabled unless explicitly enabled.
    nextWordSuggestionsEnabled: true,
  }),
});

// Later, when the host is removed:
input.destroy();

The host remains the source of truth for text and selection. The component handles input, selection changes, cursor-relative placement, keyboard navigation, candidate rendering, acceptance, dismissal, and whole committed word deletion. A physical Space can remain a normal visible space while an accepted suggestion uses a separate invisible completion boundary.

Current-word completion is enabled by default. Next-word prediction is opt-in: set nextWordSuggestionsEnabled: true when the host wants it.

For a custom editor, use the controller directly and provide readHostState/replaceHostRange instead of relying on textarea APIs. For a contenteditable host, createContentEditableAdapter provides those functions and can be passed to createWebInputComponent.

The component does not impose a UI language. Hosts can pass translated labels to their own controls and use getNavigationLabels to localize suggestion navigation text. The sample includes English/Khmer switching for this layer.

Browser asset caching and preferences

The web package also provides optional host-controlled helpers for production runtime assets and UI settings:

import {
  loadCachedResponse,
  readWebInputPreferences,
  writeWebInputPreferences,
} from "@kkeyboard/web";

const response = await loadCachedResponse("/assets/runtime-core.bundle", {
  cacheName: "my-app-kkeyboard-runtime-v1",
});
const preferences = readWebInputPreferences({
  key: "my-app.kkeyboard.preferences.v1",
  defaults: { completionEnabled: true },
});
writeWebInputPreferences(preferences, {
  key: "my-app.kkeyboard.preferences.v1",
});

loadCachedResponse uses Cache Storage when available, returns a cached asset immediately, and refreshes it in the background. Use an application-specific cache name and bump its version when the runtime format changes. Native clients should use their platform equivalent rather than browser storage.

The preference helpers use localStorage when available and fall back to a small same-origin cookie for embedded browsers that expose but restrict localStorage. Hosts can pass explicit storage and document adapters for tests or non-browser runtimes.