Skip to content

Commit

Permalink
Merge pull request madrobby#20 from TrevorBurnham/master
Browse files Browse the repository at this point in the history
Unicode for ctrl key
  • Loading branch information
madrobby committed Sep 8, 2011
2 parents de7f9eb + a22dd4a commit 7ffa556
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
8 changes: 4 additions & 4 deletions keymaster.js
Expand Up @@ -10,9 +10,9 @@
// modifier keys
_MODIFIERS = {
'⇧': 16, shift: 16,
option: 18, '⌥': 18, alt: 18,
ctrl: 17, control: 17,
command: 91, '⌘': 91
'⌥': 18, alt: 18, option: 18,
'⌃': 17, ctrl: 17, control: 17,
'⌘': 91, command: 91
},
// special keys
_MAP = {
Expand All @@ -27,7 +27,7 @@
',': 188, '.': 190, '/': 191,
'`': 192, '-': 189, '=': 187,
';': 186, '\'': 222,
'[': 219, ']': 221, '\\': 220
'[': 219, ']': 221, '\\': 220
};

for(k=1;k<20;k++) _MODIFIERS['f'+k] = 111+k;
Expand Down
2 changes: 1 addition & 1 deletion keymaster.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 13 additions & 9 deletions test/keymaster.html
Expand Up @@ -39,10 +39,12 @@ <h1>Keymaster unit tests</h1>
(el||document).dispatchEvent(event);
}

var KEYS = { '⇧': 16, shift: 16,
option: 18, '⌥': 18, alt: 18,
ctrl: 17, control: 17,
command: 91, '⌘': 91 };
var KEYS = {
'⇧': 16, shift: 16,
'⌥': 18, alt: 18, option: 18,
'⌃': 17, ctrl: 17, control: 17,
'⌘': 91, command: 91
};

Evidence.TestCase.extend('KeymasterTest', {
testShortcut: function(t){
Expand Down Expand Up @@ -106,15 +108,17 @@ <h1>Keymaster unit tests</h1>

testFancyModifierKeys: function(t){
var sequence = '';
key('+a', function(){ sequence += 'a' });
key('+a', function(){ sequence += 'a' });
key('⌥+b', function(){ sequence += 'b' });
key('⌘+c', function(){ sequence += 'c' });
key('⇧+c', function(){ sequence += 'c' });
key('⌘+d', function(){ sequence += 'd' });

keydown(KEYS.shift); keydown(65); keyup(65); keyup(KEYS.shift);
keydown(KEYS.ctrl); keydown(65); keyup(65); keyup(KEYS.ctrl);
keydown(KEYS.option); keydown(66); keyup(66); keyup(KEYS.option);
keydown(KEYS.command); keydown(67); keyup(67); keyup(KEYS.command);
keydown(KEYS.shift); keydown(67); keyup(67); keyup(KEYS.shift);
keydown(KEYS.command); keydown(68); keyup(68); keyup(KEYS.command);

t.assertEqual('abc', sequence);
t.assertEqual('abcd', sequence);
},

testNonAlphanumericKeys: function(t){
Expand Down

0 comments on commit 7ffa556

Please sign in to comment.