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

@cogizmo/fluid-hotkey-event

v0.7.2

Published

Key handler that dispatches a custom event based on specified key combinations.

Downloads

46

Readme

<fluid-hotkey-event>

Creates a generic key handler that emits a new event when the specified key combination is hit. This component is meant to be consumed by other apps and custom elements and, in best practice, is not utilized on its own.

Note: All releases until this notes are removed are to be considered prerelease status, without regard to version number.

Usage

Emits an event when a KeyboardEvent with the specified key(s) is captured on element nodes that are being listened to.

<fluid-hotkey-event keys="ctrl+s" emits="save">
</fluid-triggered-method>

Installation

<fluid-hotkey-event> is available on NPM and may be installed as a dependency.

> npm install @cogizmo/fluid-hotkey-event
  1. Place the files on your server.

  2. Install the appropriate cogizmo/Cogizmo.

    • From npm
    > npm install @cogizmo/cogizmo
    • From github
  3. Add Cogizmo to your document <head>.

    <script src="path/to/cogizmo/Cogizmo.js"></script>
  4. Add <fluid-hotkey-event> element to your document.

    <script src="path/to/fluid-hotkey-event/component.js"></script>
  5. Use element whereever you want to transclude html.

    <fluid-hotkey-event></fluid-hotkey-event>

Declarative API (HTML)

bubbles attribute

Boolean = false

Whether or not to allow the event emitted by emits to bubble through the DOM.

<fluid-hotkey-event keys="alt+f4" emits="close" bubbles>
</fluid-hotkey-event>

composed attribute

Boolean = false

Whether or not to allow bubbling event emitted by emits to penetrate Shadow DOM barriers.

<fluid-hotkey-event keys="alt+f4" emits="close" bubbles composed>
</fluid-hotkey-event>

emits attribute

String<EventName> Required

The type of event to emit when a KeyboardEvent that is captured matches one or more keys.

<fluid-hotkey-event keys="ctrl+a" emits="select-all">
</fluid-hotkey-event>

event attribute

String ("up" | "down" | "press") = "up"

The unprefixed KeyboardEvent to listen for: keydown, keypress or keyup

<fluid-hotkey-event keys="enter space" emits="select-item">
</fluid-hotkey-event>

keys attribute

String Required

Space separated list of key combinations to match KeyboardEvents against.

<fluid-hotkey-event keys="enter space" emits="select-item">
</fluid-hotkey-event>

prevent attribute

Boolean = false

Whether or not call preventDefault() on handled KeyboardEvents.

<fluid-hotkey-event keys="alt+f4" prevent emits="do-not-close" bubbles composed>
</fluid-hotkey-event>

select attribute

String<CSSSelector>

Used by element.querySelectorAll to attach the KeyboardEvent listeners.

<fluid-hotkey-event keys="esc" select="input[type='text']" emits="reset">
</fluid-hotkey-event>

stop attribute

Boolean = false

Whether or not call stopPropagation() on handled KeyboardEvents.

<fluid-hotkey-event keys="alt+f4" stop emits="do-not-close" bubbles composed>
</fluid-hotkey-event>

Imperative API (JS)

element.bubbles

Returns Boolean = false

Whether or not to allow the event emitted by emits to bubble through the DOM.

element.composed

Returns Boolean = false

Whether or not to allow bubbling event emitted by emits to penetrate Shadow DOM barriers.

element.emits ReadOnly

Returns String<EventName>

The event.type that will be emitted when the appropriate KeyboardEvent is matched.

element.keyEvent ReadOnly

Returns String ("keyup" | "keydown" | "keypress") = "keyup"

The prefixed KeyboardEvent this <fluid-hotkey-event> is listening for.

element.keys ReadOnly

Returns Array

element.nodes ReadOnly

Returns Array

List of nodes returned when queried using element.selector.

element.preventDefault

Returns Boolean = false

Whether or not to call preventDefault() on handled KeyboardEvents

element.selector ReadOnly

Returns String<CSSSelector>

Selector that is used to add the event listeners.

element.stopPropagation

Returns Boolean = false

Whether or not to call stopPropagation() on handled KeyboardEvents

DOM Events