Permalink
Browse files

Add compatibility for IE 8+

  • Loading branch information...
1 parent 845c3cc commit 0f660d2dabd9ad51588e26f9a0ad9e28bccb23fd Jesse Stuart committed Feb 9, 2012
Showing with 11 additions and 8 deletions.
  1. +6 −4 script/manager.coffee
  2. +5 −4 script/manager.js
View
@@ -3,10 +3,10 @@ class Manager
# iPad support (tap header to enable keyboard)
@$hidden_input = ($ "<textarea type='text' class='hidden-input' value='Q'></textarea>").prependTo @base.$container
- ($ window).bind 'keypress', @processKeyPress
- ($ window).bind 'keydown', @processKeyDown
- ($ window).bind 'keyup', @processKeyUp
- ($ window).bind 'focus', =>
+ ($ document).bind 'keypress', @processKeyPress
+ ($ document).bind 'keydown', @processKeyDown
+ ($ document).bind 'keyup', @processKeyUp
+ ($ document).bind 'focus', =>
for keyCode in[KEYS.CONTROL, KEYS.COMMAND, KEYS.OPTION, KEYS.SHIFT]
@base.keyboard.deselectKey null, keyCode
@@ -17,6 +17,8 @@ class Manager
return null if e.keyCode == KEYS.BACKSPACE
+ e.charCode ||= e.which # IE compatibility
+
space = @base.page.current_space
if space && space.match(e.charCode)
space.hit()
View
@@ -9,10 +9,10 @@ Manager = (function() {
this.processKeyDown = __bind(this.processKeyDown, this);
this.processKeyPress = __bind(this.processKeyPress, this);
this.$hidden_input = ($("<textarea type='text' class='hidden-input' value='Q'></textarea>")).prependTo(this.base.$container);
- ($(window)).bind('keypress', this.processKeyPress);
- ($(window)).bind('keydown', this.processKeyDown);
- ($(window)).bind('keyup', this.processKeyUp);
- ($(window)).bind('focus', __bind(function() {
+ ($(document)).bind('keypress', this.processKeyPress);
+ ($(document)).bind('keydown', this.processKeyDown);
+ ($(document)).bind('keyup', this.processKeyUp);
+ ($(document)).bind('focus', __bind(function() {
var keyCode, _i, _len, _ref, _results;
_ref = [KEYS.CONTROL, KEYS.COMMAND, KEYS.OPTION, KEYS.SHIFT];
_results = [];
@@ -28,6 +28,7 @@ Manager = (function() {
var space;
this.$hidden_input.val('Q');
if (e.keyCode === KEYS.BACKSPACE) return null;
+ e.charCode || (e.charCode = e.which);
space = this.base.page.current_space;
if (space && space.match(e.charCode)) {
space.hit();

0 comments on commit 0f660d2

Please sign in to comment.