Skip to content

Commit

Permalink
De-dupe alias and code objects.
Browse files Browse the repository at this point in the history
Moved dupe codes from `codes` to `aliases`. Removed things from
`aliases` that were already in `codes`. Added a test for common
modifier keys.
  • Loading branch information
greim committed Feb 3, 2015
1 parent c824685 commit 0e558cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
13 changes: 5 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ var codes = exports.code = exports.codes = {
'down': 40,
'insert': 45,
'delete': 46,
'windows': 91,
'command': 91,
'right click': 93,
'numpad *': 106,
Expand All @@ -88,20 +87,18 @@ var codes = exports.code = exports.codes = {
'\\': 220,
']': 221,
"'": 222,
'⇧': 16,
'⌥': 18,
'⌃': 17,
'⌘': 91,
}

// Helper aliases

var aliases = exports.aliases = {
'shift': 16,
'windows': 91,
'⇧': 16,
'⌥': 18,
'⌃': 17,
'⌘': 91,
'ctl': 17,
'ctrl': 17,
'control': 17,
'alt': 18,
'option': 18,
'pause': 19,
'break': 19,
Expand Down
5 changes: 5 additions & 0 deletions test/keycode.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ it('exposes keycode/name maps', function() {
}
})

it('should return shift, ctrl, and alt for 16, 17, and 18', function() {
assert.strictEqual(keycode(16), 'shift')
assert.strictEqual(keycode(17), 'ctrl')
assert.strictEqual(keycode(18), 'alt')
})

0 comments on commit 0e558cf

Please sign in to comment.