Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solid-primitives/keyboard

Package Overview
Dependencies
Maintainers
3
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/keyboard

A library of reactive promitives helping handling user's keyboard input.

  • 0.0.100
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10K
decreased by-22.58%
Maintainers
3
Weekly downloads
 
Created
Source

Solid Primitives keyboard

@solid-primitives/keyboard

lerna size version stage

A library of reactive promitives helping handling user's keyboard input.

Installation

npm install @solid-primitives/keyboard
# or
yarn add @solid-primitives/keyboard

makeKeyHoldListener

Attaches keyboard event-listeners to window, and calls provided callback whenever user holds or stops holding specified key.

Event listeners are automatically cleaned on root dispose.

How to use it

makeKeyHoldListener takes three arguments:

  • key keyboard key or modifier to listen for
  • onHoldChange callback fired when the hold state changes
  • options additional configuration:
    • preventDefault — call e.preventDefault() on the keyboard event, when the specified key is pressed. (Defaults to false)
    • allowOtherKeys — Should the user be allowed to press other keys while holding the specified one (Defaults to false)
import { makeKeyHoldListener } from "@solid-primitives/keyboard";

const [pressing, setPressing] = createSignal(false);

makeKeyHoldListener("altKey", setPressing, {
  preventDefault: true
});

<p>Is pressing Alt? {pressing() ? "YES" : "NO"}</p>;

Changelog

Expand Changelog

0.0.100

Initial release as a Stage-0 primitive.

Keywords

FAQs

Package last updated on 19 Jun 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc