Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thiagogarbazza/key-code

Library for key-code constants in ECMAScript/Javascript
https://github.com/thiagogarbazza/key-code

ecmascript enumeration javascript keyboard-code keyboard-key-code

Last synced: about 1 month ago
JSON representation

Library for key-code constants in ECMAScript/Javascript

Awesome Lists containing this project

README

        

# key-code
[![Build Status](https://travis-ci.org/thiagogarbazza/key-code.svg?branch=master)](https://travis-ci.org/thiagogarbazza/key-code)
[![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/thiagogarbazza/key-code/)

Library for key-code constants in ECMAScript/Javascript

For more information [see this](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode#Constants_for_keyCode_value).

See [key-code.js](src/key-code.js) for a full list of all the constants

## Installation

### Using NPM

```sh
npm install --save key-code
```

### Using Bower

```sh
bower install --save key-code
```

## Usage

### Using NodeJs

Include the package using CommonJS require()
```js
var KeyCode = require('key-code');
```

or ES2015 import:
```js
// ES2015+
import KeyCode from 'key-code';
```

### Using Browser

```html

```

```js
function myFunction(event) {
if (event.keyCode === KeyCode.ENTER) {
alert('keypress ENTER');
}
}
```

### Using Browser via CDN - [jsdelivr](https://www.jsdelivr.com)

```html

```

```js
function myFunction(event) {
if (event.keyCode === KeyCode.ENTER) {
alert('keypress ENTER');
}
}
```

## License

The `key-code` project is under MIT license.