Permalink
Browse files

arrow key error

1 parent 9fb178f commit 83ac6d482d8676adc39fd9bb23295bb48a286884 @jaridmargolin jaridmargolin committed Oct 29, 2013
Showing with 32 additions and 26 deletions.
  1. +9 −7 lib/formatter.js
  2. +1 −1 lib/formatter.min.js
  3. +9 −7 lib/jquery.formatter.js
  4. +1 −1 lib/jquery.formatter.min.js
  5. +8 −4 src/formatter.js
  6. +1 −3 src/utils.js
  7. +1 −1 test/fake-user/keys.js
  8. +2 −2 test/fake-user/user.js
View
@@ -113,13 +113,17 @@ Formatter.prototype._keyDown = function (evt) {
//
Formatter.prototype._keyPress = function (evt) {
// The first thing we need is the character code
- var k;
+ var k, isSpecial;
// Mozilla will trigger on special keys and assign the the value 0
// We want to use that 0 rather than the keyCode it assigns.
- k = (evt.which || evt.which === 0) ? evt.which : evt.keyCode;
-
+ if (evt.which) {
+ k = evt.which;
+ } else {
+ k = evt.keyCode;
+ isSpecial = utils.isSpecialKey(k);
+ }
// Process the keyCode and prevent default
- if (!utils.isSpecialKey(k) && !utils.isModifier(evt)) {
+ if (!utils.isDelKey(k) && !isSpecial && !utils.isModifier(evt)) {
this._processKey(String.fromCharCode(k), false);
return utils.preventDefault(evt);
}
@@ -567,9 +571,7 @@ utils.isSpecialKey = function (k) {
'40': 'downarrow'
};
// If del or special key
- return (this.isDelKey(k) || codes[k])
- ? true
- : false;
+ return codes[k];
};
//
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -110,13 +110,17 @@ Formatter.prototype._keyDown = function (evt) {
//
Formatter.prototype._keyPress = function (evt) {
// The first thing we need is the character code
- var k;
+ var k, isSpecial;
// Mozilla will trigger on special keys and assign the the value 0
// We want to use that 0 rather than the keyCode it assigns.
- k = (evt.which || evt.which === 0) ? evt.which : evt.keyCode;
-
+ if (evt.which) {
+ k = evt.which;
+ } else {
+ k = evt.keyCode;
+ isSpecial = utils.isSpecialKey(k);
+ }
// Process the keyCode and prevent default
- if (!utils.isSpecialKey(k) && !utils.isModifier(evt)) {
+ if (!utils.isDelKey(k) && !isSpecial && !utils.isModifier(evt)) {
this._processKey(String.fromCharCode(k), false);
return utils.preventDefault(evt);
}
@@ -564,9 +568,7 @@ utils.isSpecialKey = function (k) {
'40': 'downarrow'
};
// If del or special key
- return (this.isDelKey(k) || codes[k])
- ? true
- : false;
+ return codes[k];
};
//
Oops, something went wrong.

0 comments on commit 83ac6d4

Please sign in to comment.