Skip to content

Commit

Permalink
Add alias for command on Firefox timoxley#50
Browse files Browse the repository at this point in the history
  • Loading branch information
davekinkead committed Sep 19, 2018
1 parent 332547e commit 8e476eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ var codes = exports.code = exports.codes = {
'[': 219,
'\\': 220,
']': 221,
"'": 222
"'": 222,
'command (firefox)': 224
}

// Helper aliases
Expand All @@ -139,7 +140,8 @@ var aliases = exports.aliases = {
'pgdn': 34,
'ins': 45,
'del': 46,
'cmd': 91
'cmd': 91,
'command': 224
}

/*!
Expand Down
12 changes: 11 additions & 1 deletion test/keycode.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ it('should return shift, ctrl, and alt for 16, 17, and 18', function() {
assert.strictEqual(keycode(18), 'alt')
})

it('should return command code for all broswers', function() {
assert.strictEqual(keycode(91), 'left command'); // Chrome and Safari
assert.strictEqual(keycode(224), 'command (firefox)'); // Firefox
})

describe('isEventKey', function() {

it('should allow to compare events to their names', function() {
Expand All @@ -118,7 +123,7 @@ describe('isEventKey', function() {
assert.strictEqual(keycode.isEventKey(event, 'dOWN'), false);
});

it('should allow to compare events to their keyCodes)', function() {
it('should allow to compare events to their keyCodes', function() {
var event = { which: 13, keyCode: 13, charCode: 13 };
assert.strictEqual(keycode.isEventKey(event, 13), true);
assert.strictEqual(keycode.isEventKey(event, 14), false);
Expand All @@ -130,5 +135,10 @@ describe('isEventKey', function() {
assert.strictEqual(keycode.isEventKey(event, 'down'), false);
});

it('should alias `command` in firefox', function() {
var event = { which: 224, keyCode: 224, charCode: 0 };
assert.strictEqual(keycode.isEventKey(event, 'command'), true);
});

});

0 comments on commit 8e476eb

Please sign in to comment.