Skip to content

Commit

Permalink
Bump version to 0.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
kugaevsky committed Jul 8, 2013
1 parent d11f731 commit 9bad0bf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
33 changes: 30 additions & 3 deletions vendor/assets/javascripts/mousetrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -174,6 +174,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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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';
}

/**
Expand All @@ -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;
}
Expand Down

0 comments on commit 9bad0bf

Please sign in to comment.