Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bump version to 0.0.11

  • Loading branch information...
commit 9bad0bfada95893b3497e9157132476a6e3dc104 1 parent d11f731
@kugaevsky authored
Showing with 36 additions and 5 deletions.
  1. +6 −2 CHANGELOG.md
  2. +30 −3 vendor/assets/javascripts/mousetrap.js
View
8 CHANGELOG.md
@@ -1,8 +1,12 @@
-## v0.0.11.wip
+## v0.0.12.wip
-* Add update mousetrap.js rake task
* [] Add moustrap extensions generator
+## v0.0.11
+
+* add update mousetrap.js rake task
+* update mousetrap.js to 1.4.4
+
## v0.0.10
* update mousetrap.js to 1.4.1
View
33 vendor/assets/javascripts/mousetrap.js
@@ -17,7 +17,7 @@
* Mousetrap is a simple keyboard shortcut library for Javascript with
* no external dependencies
*
- * @version 1.4.1
+ * @version 1.4.4
* @url craig.is/killing/mice
*/
(function() {
@@ -175,6 +175,13 @@
_ignoreNextKeyup = false,
/**
+ * temporary state where we will ignore the next keypress
+ *
+ * @type {boolean}
+ */
+ _ignoreNextKeypress = false,
+
+ /**
* are we currently inside of a sequence?
* type of action ("keyup" or "keydown" or "keypress") or false
*
@@ -239,6 +246,12 @@
character = character.toLowerCase();
}
+ // String.fromCharCode(32) for spacebar returns " " for the
+ // character name, make sure it matches the mousetrap name
+ if (character == ' ') {
+ return 'space';
+ }
+
return character;
}
@@ -496,9 +509,22 @@
// modifier keys are ignored because you can have a sequence
// that contains modifiers such as "enter ctrl+space" and in most
// cases the modifier key will be pressed before the next key
- if (e.type == _nextExpectedAction && !_isModifier(character)) {
+ //
+ // also if you have a sequence such as "ctrl+b a" then pressing the
+ // "b" key will trigger a "keypress" and a "keydown"
+ //
+ // the "keydown" is expected when there is a modifier, but the
+ // "keypress" ends up matching the _nextExpectedAction since it occurs
+ // after and that causes the sequence to reset
+ //
+ // we ignore keypresses in a sequence that directly follow a keydown
+ // for the same character
+ var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress;
+ if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) {
_resetSequences(doNotReset);
}
+
+ _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown';
}
/**
@@ -522,7 +548,8 @@
return;
}
- if (e.type == 'keyup' && _ignoreNextKeyup == character) {
+ // need to use === for the character check because the character can be 0
+ if (e.type == 'keyup' && _ignoreNextKeyup === character) {
_ignoreNextKeyup = false;
return;
}
Please sign in to comment.
Something went wrong with that request. Please try again.