+38
-28
| 'use strict'; | ||
| var keys = { | ||
| ctrl: 17, | ||
| control: 17, | ||
| alt: 18, | ||
| option: 18, | ||
| shift: 16, | ||
| windows: 91, | ||
| command: 91, | ||
| esc: 27, | ||
| escape: 27, | ||
| 'ctrl': 17, | ||
| 'control': 17, | ||
| 'alt': 18, | ||
| 'option': 18, | ||
| 'shift': 16, | ||
| 'windows': 91, | ||
| 'command': 91, | ||
| 'esc': 27, | ||
| 'escape': 27, | ||
| '`': 192, | ||
| '-': 189, | ||
| '=': 187, | ||
| backspace: 8, | ||
| tab: 9, | ||
| 'backspace': 8, | ||
| 'tab': 9, | ||
| '\\': 220, | ||
@@ -23,3 +23,3 @@ '[': 219, | ||
| '\'': 222, | ||
| enter: 13, | ||
| 'enter': 13, | ||
| 'return': 13, | ||
@@ -29,18 +29,18 @@ ',': 188, | ||
| '/': 191, | ||
| space: 32, | ||
| pause: 19, | ||
| 'space': 32, | ||
| 'pause': 19, | ||
| 'break': 19, | ||
| insert: 45, | ||
| 'insert': 45, | ||
| 'delete': 46, | ||
| home: 36, | ||
| end: 35, | ||
| pageup: 33, | ||
| pagedown: 34, | ||
| left: 37, | ||
| up: 38, | ||
| right: 39, | ||
| down: 40, | ||
| capslock: 20, | ||
| numlock: 144, | ||
| scrolllock: 145 | ||
| 'home': 36, | ||
| 'end': 35, | ||
| 'pageup': 33, | ||
| 'pagedown': 34, | ||
| 'left': 37, | ||
| 'up': 38, | ||
| 'right': 39, | ||
| 'down': 40, | ||
| 'capslock': 20, | ||
| 'numlock': 144, | ||
| 'scrolllock': 145 | ||
| }; | ||
@@ -57,6 +57,16 @@ | ||
| function code(input) { | ||
| return keys[input.toLowerCase()] || input.toUpperCase().charCodeAt(0); | ||
| function code (input) { | ||
| var code = keys[input.toLowerCase()]; | ||
| if (code !== undefined) { | ||
| return code; | ||
| } | ||
| if (input.length === 1) { | ||
| return input.toUpperCase().charCodeAt(0); | ||
| } | ||
| return undefined; | ||
| } | ||
| function key(input) { | ||
@@ -63,0 +73,0 @@ for (var k in keys) { |
+1
-1
| { | ||
| "name": "keycodes", | ||
| "description": "Key codes and names", | ||
| "version": "0.2.3", | ||
| "version": "0.2.4", | ||
| "keywords": [ | ||
@@ -6,0 +6,0 @@ "key", |
+5
-0
@@ -180,1 +180,6 @@ 'use strict'; | ||
| }); | ||
| test('Bogus keycodes', function (t) { | ||
| t.is(keycode(Math.POSITIVE_INFINITY), undefined); | ||
| t.is(keycode('foo'), undefined); | ||
| }); |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
8069
3.86%265
4.33%