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 🙏

© 2024 – Pkg Stats / Ryan Hefner

svelte-keyboard

v0.5.5

Published

Keyboard component for Svelte

Downloads

963

Readme

svelte-keyboard

A svelte component for when you want a permanent, on-screen keyboard. View Demo.

Installation

npm install svelte-keyboard

Usage

<script>
  import Keyboard from "svelte-keyboard";

  const onKeydown = (event) => {
    console.log(event.detail);
  }
</script>

<Keyboard on:keydown="{onKeydown}" />

Localization Layouts

  • qwerty - (default)
  • azerty

Preset Layouts

  • standard - (default) two pages with all basic keys
  • crossword - one page, just capitalized letters and Backspace
  • wordle - one page, just capitalized letters, Backspace, and Enter

Custom Layout

<script>
  const keys = [{ row: 0, value: "Q"}, ...];
</script>

<Keyboard custom="{keys}" />

If you want value to be different than the display key, pass a display property. If you want keys to be laid out on the second page, include page: 1 (defaults to page: 0) .

<Keyboard layout="wordle" />

Custom Styles

Use style props on the component (showing defaults):

<Keyboard
	--height="3.5rem"
	--background="#efefef"
	--color="currentColor"
	--border="none"
	--border-radius="2px"
	--box-shadow="none"
	--flex="1"
	--font-family="sans-serif"
	--font-size="20px"
	--font-weight="normal"
	--margin="0.125rem"
	--min-width="2rem"
	--opacity="1"
	--stroke-width="3px"
	--text-transform="none"
	--active-background="#cdcdcd"
	--active-border="none"
	--active-box-shadow="none"
	--active-color="currentColor"
	--active-opacity="1"
	--active-transform="none"
>

For any other properties, use global CSS on the selector .svelte-keyboard button.key. Note: stroke-width is for svg icons.

To give specific keys a class (e.g., "clicked") you can use the keyClass prop:

<Keyboard keyClass="{{ "x": "clicked"}}" />

The keyClass object is key/value pairs where they key is the key name (e.g., "x" or "Enter") and the value is the class name(s) to apply (e.g., "clicked" or "clicked hide"). You can then use global styling :global(.key.clicked) { ... } to apply custom styles.

Special values

  • Backspace displays a backspace svg icon
  • Enter displays an enter svg icon
  • Space displays a spacebar
  • Shift displays "ABC" or "abc" to toggle case, no event fires
  • Page1 displays "123" and will switch to the second page, no event fires
  • Page0 displays "abc" and will switch to the first page, no event fires

If you want to say the word instead of an icon, add this prop:

<Keyboard noSwap={["Enter"]} />

Development

change basepath to "" for dev and "svelte-keyboard" for deploy.

npm run dev;