mousetrapjs 0.0.8 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
@@ -1,3 +1,3 @@
1
1
  module Mousetrapjs
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/mousetrapjs.rb CHANGED
File without changes
data/mousetrapjs.gemspec CHANGED
File without changes
@@ -16,7 +16,7 @@
16
16
  * Mousetrap is a simple keyboard shortcut library for Javascript with
17
17
  * no external dependencies
18
18
  *
19
- * @version 1.1.2
19
+ * @version 1.1.3
20
20
  * @url craig.is/killing/mice
21
21
  */
22
22
  (function() {
@@ -298,15 +298,16 @@
298
298
  *
299
299
  * @param {string} character
300
300
  * @param {Array} modifiers
301
- * @param {string} action
301
+ * @param {Event|Object} e
302
302
  * @param {boolean=} remove - should we remove any matches
303
303
  * @param {string=} combination
304
304
  * @returns {Array}
305
305
  */
306
- function _getMatches(character, modifiers, action, remove, combination) {
306
+ function _getMatches(character, modifiers, e, remove, combination) {
307
307
  var i,
308
308
  callback,
309
- matches = [];
309
+ matches = [],
310
+ action = e.type;
310
311
 
311
312
  // if there are no events related to this keycode
312
313
  if (!_callbacks[character]) {
@@ -335,10 +336,14 @@
335
336
  continue;
336
337
  }
337
338
 
338
- // if this is a keypress event that means that we need to only
339
- // look at the character, otherwise check the modifiers as
340
- // well
341
- if (action == 'keypress' || _modifiersMatch(modifiers, callback.modifiers)) {
339
+ // if this is a keypress event and the meta key and control key
340
+ // are not pressed that means that we need to only look at the
341
+ // character, otherwise check the modifiers as well
342
+ //
343
+ // chrome will not fire a keypress if meta or control is down
344
+ // safari will fire a keypress if meta or meta+shift is down
345
+ // firefox will fire a keypress if meta or control is down
346
+ if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) {
342
347
 
343
348
  // remove is used so if you change your mind and call bind a
344
349
  // second time with a new function the first one is overwritten
@@ -420,7 +425,7 @@
420
425
  return;
421
426
  }
422
427
 
423
- var callbacks = _getMatches(character, _eventModifiers(e), e.type),
428
+ var callbacks = _getMatches(character, _eventModifiers(e), e),
424
429
  i,
425
430
  do_not_reset = {},
426
431
  processed_sequence_callback = false;
@@ -685,7 +690,7 @@
685
690
  }
686
691
 
687
692
  // remove an existing match if there is one
688
- _getMatches(key, modifiers, action, !sequence_name, combination);
693
+ _getMatches(key, modifiers, {type: action}, !sequence_name, combination);
689
694
 
690
695
  // add this call back to the array
691
696
  // if it is a sequence put it at the beginning
@@ -728,8 +733,7 @@
728
733
  * binds an event to mousetrap
729
734
  *
730
735
  * can be a single key, a combination of keys separated with +,
731
- * a comma separated list of keys, an array of keys, or
732
- * a sequence of keys separated by spaces
736
+ * an array of keys, or a sequence of keys separated by spaces
733
737
  *
734
738
  * be sure to list the modifier keys first to make sure that the
735
739
  * correct key ends up getting bound (the last key in the pattern)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mousetrapjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-29 00:00:00.000000000 Z
12
+ date: 2012-09-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Gem for Mousetrap, a simple library for handling keyboard shortcuts in
15
15
  Javascript
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  version: '0'
49
49
  requirements: []
50
50
  rubyforge_project:
51
- rubygems_version: 1.8.22
51
+ rubygems_version: 1.8.24
52
52
  signing_key:
53
53
  specification_version: 3
54
54
  summary: Mousetrap is a simple library for handling keyboard shortcuts in Javascript