Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support of firefox keys #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ pids
*.pid
*.seed

# Storm idea folder
.idea

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ onKeyPress = (ev) => {

## Usage

To use this module, import the `Key` enum at the top of your TypeScript file using the enum:
To use this module, import the `Key` or `FirefoxKey` (if you support firefox browser) enum at the top of your TypeScript file using the enum:

```JavaScript
import { Key } from 'ts-keycode-enum';
import { Key, FirefoxKey } from 'ts-keycode-enum';
```

You can now use a readable enum value in place of any raw keycodes throughout the file:

```JavaScript
if (ev.which === Key.Escape) { ... }
if (ev.which === Key.SemiColon || ev.which === FirefoxKey.SemiColon) { ... }
```

See [Key.enum.ts](./Key.enum.ts) for a complete list of available keys.
See [Key.enum.ts](./src/Key.enum.ts) and [FirefoxKey.enum.ts](./src/FirefoxKey.enum.ts) for a complete list of available keys.

In addition, to aid with readability, a number of enum values have aliases. For example:
In addition, to aid with readability, a number of enum values have aliases. For example:

```JavaScript
// this true - these values are equal
Expand Down
7 changes: 7 additions & 0 deletions dist/declarations/FirefoxKey.enum.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export declare enum FirefoxKey {
SemiColon = 59,
Equals = 61,
Dash = 173,
UnderScore = 173,
PlusSign = 61
}
2 changes: 2 additions & 0 deletions dist/declarations/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Key } from './Key.enum';
export { FirefoxKey } from './FirefoxKey.enum';
10 changes: 10 additions & 0 deletions dist/js/FirefoxKey.enum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var FirefoxKey;
(function (FirefoxKey) {
FirefoxKey[FirefoxKey["SemiColon"] = 59] = "SemiColon";
FirefoxKey[FirefoxKey["Equals"] = 61] = "Equals";
FirefoxKey[FirefoxKey["Dash"] = 173] = "Dash";
FirefoxKey[FirefoxKey["UnderScore"] = 173] = "UnderScore";
FirefoxKey[FirefoxKey["PlusSign"] = 61] = "PlusSign";
})(FirefoxKey = exports.FirefoxKey || (exports.FirefoxKey = {}));
6 changes: 6 additions & 0 deletions dist/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Key_enum_1 = require("./Key.enum");
exports.Key = Key_enum_1.Key;
var FirefoxKey_enum_1 = require("./FirefoxKey.enum");
exports.FirefoxKey = FirefoxKey_enum_1.FirefoxKey;
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
"name": "ts-keycode-enum",
"version": "1.0.6",
"description": "A TypeScript enum definition that maps human-friendly key names to JavaScript key codes",
"main": "dist/js/Key.enum.js",
"main": "dist/js/index.js",
"files": [
"dist/"
],
"types": "dist/declarations/Key.enum.d.ts",
"types": [
"dist/declarations/Key.enum.d.ts",
"dist/declarations/FirefoxKey.enum.d.ts"
],
"scripts": {
"build": "tsc"
},
Expand All @@ -20,6 +23,7 @@
"keycodes",
"key",
"enum",
"firefox",
"ts"
],
"author": {
Expand All @@ -33,6 +37,6 @@
},
"homepage": "https://github.com/nfriend/ts-keycode-enum#readme",
"devDependencies": {
"typescript": "^2.9.2"
"typescript": "^3.1.1"
}
}
7 changes: 7 additions & 0 deletions src/FirefoxKey.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export enum FirefoxKey {
SemiColon = 59,
Equals = 61,
Dash = 173,
UnderScore = Dash,
PlusSign = Equals,
}
2 changes: 1 addition & 1 deletion Key.enum.ts → src/Key.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ export enum Key {
OpenBracket = 219,
ClosedBracket = 221,
Quote = 222
}
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {Key} from './Key.enum';
export {FirefoxKey} from './FirefoxKey.enum';
22 changes: 11 additions & 11 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"compilerOptions": {
"declaration": true,
"declarationDir": "dist/declarations",
"module": "commonjs",
"target": "es5",
"outDir": "dist/js"
},
"files": [
"Key.enum.ts"
]
}
"compilerOptions": {
"declaration": true,
"declarationDir": "dist/declarations",
"module": "commonjs",
"target": "es5",
"outDir": "dist/js"
},
"include": [
"src/**/*"
]
}