Permalink
Browse files

Don't confuse number keys with escaped codes

If the escaped codes are in the bindings hash without the '\'
character they will get confused with the codes that map to the number
keys. Distinguish them by leaving the escape character in there.
  • Loading branch information...
1 parent 9de2ec3 commit e353cd909fcc33fbdbaef33e7c2d1689d3027522 @rhburrows committed Jun 23, 2011
Showing with 5 additions and 6 deletions.
  1. +1 −1 src/defaults.js
  2. +4 −5 src/input.js
View
@@ -92,7 +92,7 @@
// 0-9
for (var n=48; n<58; n++) {
var num = String.fromCharCode(n);
- defaultKeys[n] = insertF(num);
+ defaultKeys['\\' + n] = insertF(num);
}
$.fn.s2e.config.keybindings = defaultKeys;
View
@@ -43,9 +43,8 @@
// There's probably a better way to do this
var keyString = keys[0];
- if (keyString.indexOf('\\') == 0) {
- keyString = keyString.slice(1);
- } else if (typeof SPECIAL_KEY_STRINGS[keyString] === "undefined") {
+ if (typeof SPECIAL_KEY_STRINGS[keyString] === "undefined" &&
+ keyString.indexOf('\\') != 0) {
keyString = keyString.toUpperCase();
}
@@ -83,9 +82,9 @@
if (typeof bindings[keyString + modifiers] !== "undefined") {
e.preventDefault();
return bindings[keyString + modifiers](editor, e);
- } else if (typeof bindings["" + e.which + modifiers] !== "undefined") {
+ } else if (typeof bindings["\\" + e.which + modifiers] !== "undefined") {
e.preventDefault();
- return bindings["" + e.which + modifiers](editor, e);
+ return bindings["\\" + e.which + modifiers](editor, e);
} else {
e.preventDefault();
return true;

0 comments on commit e353cd9

Please sign in to comment.