Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
aSydiK committed Jul 8, 2010
1 parent cb6b47f commit b313f1a
Showing 1 changed file with 90 additions and 4 deletions.
94 changes: 90 additions & 4 deletions pointstream.js
Expand Up @@ -24,7 +24,7 @@ function PointStream(){
var VBOs;

// browser detection to handle differences such as mouse scrolling
var browser = -1 ;
var browser = -1;
const MINEFIELD = 0;
const CHROME = 1;
const CHROMIUM = 2;
Expand Down Expand Up @@ -339,6 +339,91 @@ function PointStream(){
return programObject;
};

/**
*/
function keyCodeMap(code, shift) {
// Letters
if (code >= 65 && code <= 90) { // A-Z
// Keys return ASCII for upcased letters.
// Convert to downcase if shiftKey is not pressed.
if (shift) {
return code;
}
else {
return code + 32;
}
}
// Numbers and their shift-symbols
else if (code >= 48 && code <= 57) { // 0-9
if (shift) {
switch (code) {
case 49:
return 33; // !
case 50:
return 64; // @
case 51:
return 35; // #
case 52:
return 36; // $
case 53:
return 37; // %
case 54:
return 94; // ^
case 55:
return 38; // &
case 56:
return 42; // *
case 57:
return 40; // (
case 48:
return 41; // )
}
}
}
// Coded keys
else if (codedKeys.indexOf(code) >= 0) { // SHIFT, CONTROL, ALT, LEFT, RIGHT, UP, DOWN
p.keyCode = code;
return p.CODED;
}
// Symbols and their shift-symbols
else {
if (shift) {
switch (code) {
case 107:
return 43; // +
case 219:
return 123; // {
case 221:
return 125; // }
case 222:
return 34; // "
}
} else {
switch (code) {
case 188:
return 44; // ,
case 109:
return 45; // -
case 190:
return 46; // .
case 191:
return 47; // /
case 192:
return 96; // ~
case 219:
return 91; // [
case 220:
return 92; // \
case 221:
return 93; // ]
case 222:
return 39; // '
}
}
}
return code;
};

/**
*/
var xb = {
Expand Down Expand Up @@ -554,19 +639,20 @@ function PointStream(){
}
},

_keyDown: function(){
_keyDown: function(evt){
key = keyCodeMap(evt.keyCode, evt.shiftKey)
if(typeof xb.keyDown === "function"){
xb.keyDown();
}
},

_keyPressed: function(){
_keyPressed: function(evt){
if(typeof xb.keyPressed === "function"){
xb.keyPressed();
}
},

_keyUp: function(){
_keyUp: function(evt){
if(typeof xb.keyUp === "function"){
xb.keyUp();
}
Expand Down

0 comments on commit b313f1a

Please sign in to comment.