Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixes in KeyboardState #21

Merged
merged 1 commit into from

2 participants

Daniel Kaneider Jerome Etienne
Daniel Kaneider

Hi,

I did some small changes

  • added enter and escape to keyboard aliases
  • added some missing semicolons (gave some warnings in Eclipse)

Cheers,
Daniel

Daniel Kaneider danielkaneider added enter and escape to keyboard aliases
added some missing semicolons (gave some warnings)
d97f4bf
Jerome Etienne jeromeetienne merged commit d97f4bf into from
Jerome Etienne

merged. thanks a bunch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 26, 2012
  1. Daniel Kaneider

    added enter and escape to keyboard aliases

    danielkaneider authored
    added some missing semicolons (gave some warnings)
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 7 deletions.
  1. +9 −7 THREEx.KeyboardState.js
16 THREEx.KeyboardState.js
View
@@ -39,7 +39,7 @@ THREEx.KeyboardState = function()
// to store the current state
this.keyCodes = {};
this.modifiers = {};
-
+
// create callback to bind/unbind keyboard events
var self = this;
this._onKeyDown = function(event){ self._onKeyChange(event, true); };
@@ -48,7 +48,7 @@ THREEx.KeyboardState = function()
// bind keyEvents
document.addEventListener("keydown", this._onKeyDown, false);
document.addEventListener("keyup", this._onKeyUp, false);
-}
+};
/**
* To stop listening of the keyboard events
@@ -58,7 +58,7 @@ THREEx.KeyboardState.prototype.destroy = function()
// unbind keyEvents
document.removeEventListener("keydown", this._onKeyDown, false);
document.removeEventListener("keyup", this._onKeyUp, false);
-}
+};
THREEx.KeyboardState.MODIFIERS = ['shift', 'ctrl', 'alt', 'meta'];
THREEx.KeyboardState.ALIAS = {
@@ -69,7 +69,9 @@ THREEx.KeyboardState.ALIAS = {
'space' : 32,
'pageup' : 33,
'pagedown' : 34,
- 'tab' : 9
+ 'enter' : 13,
+ 'tab' : 9,
+ 'escape' : 27
};
/**
@@ -89,7 +91,7 @@ THREEx.KeyboardState.prototype._onKeyChange = function(event, pressed)
this.modifiers['ctrl'] = event.ctrlKey;
this.modifiers['alt'] = event.altKey;
this.modifiers['meta'] = event.metaKey;
-}
+};
/**
* query keyboard state to know if a key is pressed of not
@@ -108,9 +110,9 @@ THREEx.KeyboardState.prototype.pressed = function(keyDesc)
}else if( Object.keys(THREEx.KeyboardState.ALIAS).indexOf( key ) != -1 ){
pressed = this.keyCodes[ THREEx.KeyboardState.ALIAS[key] ];
}else {
- pressed = this.keyCodes[key.toUpperCase().charCodeAt(0)]
+ pressed = this.keyCodes[key.toUpperCase().charCodeAt(0)];
}
if( !pressed) return false;
};
return true;
-}
+};
Something went wrong with that request. Please try again.