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

vkeyboard-react

v0.0.2

Published

A React component for a virtual keyboard with several options.

Downloads

1

Readme

React Virtual Keyboard

A React component for a virtual keyboard with several options.

Install

Install the package from npm and use inside your application.

npm i js_virtual_keyboard

Then add to your application.

import { VKeyboard, DEFAULT_KEY_MAP } from 'js-virtual-keyboard'
import 'js-virtual-keyboard/core.css'

<div>
  <VKeyboard
    keyMappings={DEFAULT_KEY_MAP}
    keypressHandler={val => console.warn(val)}
    fixedToScreen
  />
</div>

NOTE: The package comes with a default keyboard layout but you can provide your own values to manage.

Props

Rewact component props for virtual keyboard.

| Prop | Type | | ---- | ---- | | keyMappings | Array | | keypressHandler | Function | | fixedToScreen | Boolean |

Key Mappings

You can either use the provided DEFAULT_KEY_MAP or create your own.

Key mappings have 5 values you can define. Value is required, shiftValue and capValue depend on if you provide a shift and/or a cap key. If blackSpace is set to true then all other values are ignored and will use a black space instead.

const KEY_MAP_SET = [{
  value: 'q', // required
  shiftValue: '1',
  capValue: 'Q',
  icon: '',
  blankSpace: true,
  size: 1 // Supported values are 1 - 4
}]

The prop value passed is an array of array/objects like so. Each inner array is a new row for the virtual keyboard component.

const FULL_MAP = [
 [{ ... }],
 [{ ... }],
 [{ ... }]
]

Callback Function

The virtual keyboard provides a callback function of the value being clicked. You are able to consume this value and handle for the applications needs. If you provide shift or cap values inside your key mappings these values will be returned.

const cbFunc = val => {
  ... Do something with value
}

<VKeyboard
  ...
  keypressHandler={cbFunc}
/>

Styling

You can customize the virtual keyboard using CSS custom variables.

:root {
  --vk-bg: #555;
  --vk-x-padding: 6px;
  --vk-y-padding: 6px;
  --vbtn-radius: 6px;
  --vbtn-bg: #fff;
  --vbtn-color: #000;
  --vbtn-bg-active: #33339b;
  --vbtn-color-active: var(--vbtn-bg);
  --vbtn-x-padding: 12px;
  --vbtn-y-padding: 12px;
  --vbtn-shadow: 0px 1px 1px rgba(0, 0, 0, 0.4);
}

The virtual keyboard uses a global css style and classes. If you would like to further customize or write your own look at the stylesheet provided with the package or inspect the DOM.