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 alias for command on Firefox #50 #51

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
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);
});

});