diff --git a/.gitignore b/.gitignore index 5148e52..50f512b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ pids *.pid *.seed +# Storm idea folder +.idea + # Directory for instrumented libs generated by jscoverage/JSCover lib-cov diff --git a/README.md b/README.md index f158984..09da9ae 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/dist/declarations/FirefoxKey.enum.d.ts b/dist/declarations/FirefoxKey.enum.d.ts new file mode 100644 index 0000000..2c649a6 --- /dev/null +++ b/dist/declarations/FirefoxKey.enum.d.ts @@ -0,0 +1,7 @@ +export declare enum FirefoxKey { + SemiColon = 59, + Equals = 61, + Dash = 173, + UnderScore = 173, + PlusSign = 61 +} diff --git a/dist/declarations/index.d.ts b/dist/declarations/index.d.ts new file mode 100644 index 0000000..cea510a --- /dev/null +++ b/dist/declarations/index.d.ts @@ -0,0 +1,2 @@ +export { Key } from './Key.enum'; +export { FirefoxKey } from './FirefoxKey.enum'; diff --git a/dist/js/FirefoxKey.enum.js b/dist/js/FirefoxKey.enum.js new file mode 100644 index 0000000..20ce57f --- /dev/null +++ b/dist/js/FirefoxKey.enum.js @@ -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 = {})); diff --git a/dist/js/index.js b/dist/js/index.js new file mode 100644 index 0000000..4606e6e --- /dev/null +++ b/dist/js/index.js @@ -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; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..c41362c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,14 @@ +{ + "name": "ts-keycode-enum", + "version": "1.0.6", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "typescript": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.1.tgz", + "integrity": "sha512-Veu0w4dTc/9wlWNf2jeRInNodKlcdLgemvPsrNpfu5Pq39sgfFjvIIgTsvUHCoLBnMhPoUA+tFxsXjU6VexVRQ==", + "dev": true + } + } +} diff --git a/package.json b/package.json index 44bc4dc..e7e88c5 100644 --- a/package.json +++ b/package.json @@ -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" }, @@ -20,6 +23,7 @@ "keycodes", "key", "enum", + "firefox", "ts" ], "author": { @@ -33,6 +37,6 @@ }, "homepage": "https://github.com/nfriend/ts-keycode-enum#readme", "devDependencies": { - "typescript": "^2.9.2" + "typescript": "^3.1.1" } } diff --git a/src/FirefoxKey.enum.ts b/src/FirefoxKey.enum.ts new file mode 100644 index 0000000..d5ff76b --- /dev/null +++ b/src/FirefoxKey.enum.ts @@ -0,0 +1,7 @@ +export enum FirefoxKey { + SemiColon = 59, + Equals = 61, + Dash = 173, + UnderScore = Dash, + PlusSign = Equals, +} diff --git a/Key.enum.ts b/src/Key.enum.ts similarity index 99% rename from Key.enum.ts rename to src/Key.enum.ts index ad8d986..364ad1c 100644 --- a/Key.enum.ts +++ b/src/Key.enum.ts @@ -124,4 +124,4 @@ export enum Key { OpenBracket = 219, ClosedBracket = 221, Quote = 222 -} \ No newline at end of file +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..2c08023 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,2 @@ +export {Key} from './Key.enum'; +export {FirefoxKey} from './FirefoxKey.enum'; diff --git a/tsconfig.json b/tsconfig.json index 538892e..48137d3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,12 @@ { - "compilerOptions": { - "declaration": true, - "declarationDir": "dist/declarations", - "module": "commonjs", - "target": "es5", - "outDir": "dist/js" - }, - "files": [ - "Key.enum.ts" - ] -} \ No newline at end of file + "compilerOptions": { + "declaration": true, + "declarationDir": "dist/declarations", + "module": "commonjs", + "target": "es5", + "outDir": "dist/js" + }, + "include": [ + "src/**/*" + ] +}