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

keycoder

v1.1.1

Published

A lightweight JavaScript library for interpreting event key and character codes across browsers.

Downloads

11,964

Readme

Keycoder

npm version Build Status Coverage Status Dependency Status devDependency Status

A lightweight JavaScript library for interpreting event key and character codes across browsers. Keycoder implements UMD for CommonJS, AMD, and global based loading support.

Keycoder is released under the MIT license.

Modules

Classes

Keycoder

Keycoder.key : object

An object containing references to all named keys.

Kind: static property of Keycoder
Properties

| Name | Type | | --- | --- | | BACKSPACE | Key | | TAB | Key | | ENTER | Key | | SHIFT | Key | | CONTROL | Key | | ALT | Key | | PAUSE | Key | | BREAK | Key | | CAPS_LOCK | Key | | ESCAPE | Key | | WINDOWS | Key | | COMMAND | Key | | OPTION | Key | | PRINT_SCREEN | Key | | NUM_LOCK | Key | | MAC_NUM_LOCK | Key | | SCROLL_LOCK | Key | | PAGE_UP | Key | | PAGE_DOWN | Key | | END | Key | | HOME | Key | | LEFT_ARROW | Key | | UP_ARROW | Key | | RIGHT_ARROW | Key | | DOWN_ARROW | Key | | INSERT | Key | | DELETE | Key | | NUMPAD_0 | Key | | NUMPAD_1 | Key | | NUMPAD_2 | Key | | NUMPAD_3 | Key | | NUMPAD_4 | Key | | NUMPAD_5 | Key | | NUMPAD_6 | Key | | NUMPAD_7 | Key | | NUMPAD_8 | Key | | NUMPAD_9 | Key | | NUMPAD_MULTIPLY | Key | | NUMPAD_PLUS | Key | | NUMPAD_MINUS | Key | | NUMPAD_DECIMAL | Key | | NUMPAD_DIVIDE | Key | | NUMPAD_MIDDLE | Key |

Keycoder.toCharacter(keyCode, shift) ⇒ string | null

Kind: static method of Keycoder
Returns: string | null - The character for the keycode and shift state. Null if the key is not a printable character.

| Param | Type | Description | | --- | --- | --- | | keyCode | number | An IE or Mozilla key code | | shift | boolean | The shift key state. A value of true indicates it is pressed, false that it is not |

Keycoder.charCodeToCharacter(charCode) ⇒ string | null

Kind: static method of Keycoder
Returns: string | null - Returns the character for the character code. Null if the key is not a printable character.

| Param | Type | Description | | --- | --- | --- | | charCode | number | An ASCII character code |

Keycoder.eventToCharacter(event) ⇒ string | null

Kind: static method of Keycoder
Returns: string | null - - The character pressed in the key event. Null if the key pressed is not a printable character, or the event is not a key event.

| Param | Type | Description | | --- | --- | --- | | event | number | A keydown, keyup, or keypress event object |

Keycoder.fromCharacter(character) ⇒ Key | null

Kind: static method of Keycoder
Returns: Key | null - A Key object. Null if no key is associated with the provided code.

| Param | Type | | --- | --- | | character | string |

Keycoder.fromKeyCode(keyCode) ⇒ Key | null

Kind: static method of Keycoder
Returns: Key | null - A Key object. Null if no key is associated with the provided code.

| Param | Type | Description | | --- | --- | --- | | keyCode | number | A IE or Mozilla key code |

Keycoder.fromCharCode(charCode) ⇒ Key | null

Maps an ASCII character code to a Key object

Kind: static method of Keycoder
Returns: Key | null - A Key object. Null if no key is associated with the provided code.

| Param | Type | Description | | --- | --- | --- | | charCode | number | An ASCII character code |

Keycoder.fromEvent(event) ⇒ Key | null

Maps a keypress, keydown, or keyup event object to a key

Kind: static method of Keycoder
Returns: Key | null - A Key object. Null if no key was pressed in the provided event.

| Param | Type | Description | | --- | --- | --- | | event | object | A keydown, keyup, or keypress event object |

Keycoder.allKeys() ⇒ Array.<Key>

Kind: static method of Keycoder
Returns: Array.<Key> - An array of Key objects for all keys

Key

Kind: global class
Internal:
Properties

| Name | Type | Description | | --- | --- | --- | | names | Array.<string> | Names that the key is called. Ex. "BACKSPACE", "INSERT" | | keyCode.ie | number | IE key code | | keyCode.mozilla | number | Mozillia key code | | character | string | null | Key character | | charCode | number | null | ASCII character code | | shift.character | string | null | Key shift character | | shift.charCode | number | null | Shift ASCII character code |

new Key()

A representation of a keyboard key. This class cannot be instantiated manually. All instances are generated by the Keycoder module.

key.isPrintableCharacter() ⇒ boolean

Kind: instance method of Key
Returns: boolean - If the key is a printable character

key.hasCharCode() ⇒ boolean

Kind: instance method of Key
Returns: boolean - If the key has a character code

key.hasDistinctShiftCharacter() ⇒ boolean

Kind: instance method of Key
Returns: boolean - If the key's character and shift character are different

key.equals(other) ⇒ boolean

Kind: instance method of Key
Returns: boolean - True if the key and the compared key/code are the same key

| Param | Type | Description | | --- | --- | --- | | other | Key | number | A Key object or key code |