diff --git a/index.js b/index.js index 9dc7ce1..b509e54 100644 --- a/index.js +++ b/index.js @@ -114,7 +114,8 @@ var codes = exports.code = exports.codes = { '[': 219, '\\': 220, ']': 221, - "'": 222 + "'": 222, + 'command (firefox)': 224 } // Helper aliases @@ -139,7 +140,8 @@ var aliases = exports.aliases = { 'pgdn': 34, 'ins': 45, 'del': 46, - 'cmd': 91 + 'cmd': 91, + 'command': 224 } /*! diff --git a/test/keycode.js b/test/keycode.js index bd10f2c..34e338a 100644 --- a/test/keycode.js +++ b/test/keycode.js @@ -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() { @@ -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); @@ -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); + }); + });