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

keyz

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keyz

Set of constants indentyfying keyboard keys.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Keyz is very simple library for use in the JS enviroment.

It exposes single immutable object containing constants for keyboard keys.

Instalation

You can install it from npm:

npm install keyz --save

Or you can download keyz.min.js from the dist folder and then include it in html file:

<script src="keyz.min.js"></script>

Usage

Usually handler listening for events of specific key is created like this:

element.addEventListener("keydown", function(event) {
    if (event.keyCode == 13) {
        //do something
    }
})

It involves using magic numbers (like 13 in this example), which can make code hard to uderstand.

This library provides set of self-explaining constants, which can be imported and used like this:

import Keys from 'keyz'

element.addEventListener("keydown", function(event) {
    if (event.keyCode == Keys.ENTER) {
        //do something
    }
})

You can also import constants for specific keys:

import { PAGE_UP } from 'keyz'

element.addEventListener("keydown", function(event) {
    if (event.keyCode == PAGE_UP) {
        //do something
    }
})

List of all values:

KeyValue
BACKSPACE8
TAB9
ENTER13
SHIFT16
CTRL17
ALT18
PAUSE19
CAPS_LOCK20
ESCAPE27
SPACE32
PAGE_UP33
PAGE_DOWN34
END35
HOME36
LEFT37
UP38
RIGHT39
DOWN40
INSERT45
DELETE46
KEY_048
KEY_149
KEY_250
KEY_351
KEY_452
KEY_553
KEY_654
KEY_755
KEY_856
KEY_957
KEY_A65
KEY_B66
KEY_C67
KEY_D68
KEY_E69
KEY_F70
KEY_G71
KEY_H72
KEY_I73
KEY_J74
KEY_K75
KEY_L76
KEY_M77
KEY_N78
KEY_O79
KEY_P80
KEY_Q81
KEY_R82
KEY_S83
KEY_T84
KEY_U85
KEY_V86
KEY_W87
KEY_X88
KEY_Y89
KEY_Z90
LEFT_META91
RIGHT_META92
SELECT93
NUMPAD_096
NUMPAD_197
NUMPAD_298
NUMPAD_399
NUMPAD_4100
NUMPAD_5101
NUMPAD_6102
NUMPAD_7103
NUMPAD_8104
NUMPAD_9105
MULTIPLY106
ADD107
SUBTRACT109
DECIMAL110
DIVIDE111
F1112
F2113
F3114
F4115
F5116
F6117
F7118
F8119
F9120
F10121
F11122
F12123
NUM_LOCK144
SCROLL_LOCK145
SEMICOLON186
EQUALS187
COMMA188
DASH189
PERIOD190
FORWARD_SLASH191
GRAVE_ACCENT192
OPEN_BRACKET219
BACK_SLASH220
CLOSE_BRACKET221
SINGLE_QUOTE222

Keywords

FAQs

Package last updated on 04 Nov 2017

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