Removed keymap (merged into keyboard), fixed JS semicolons, etc.

This commit is contained in:
Michael Jumper
2011-07-03 15:32:06 -07:00
parent 23ed11a933
commit fbce63ea64
4 changed files with 68 additions and 102 deletions

View File

@@ -19,6 +19,52 @@
function GuacamoleKeyboard(element) {
// Keymap
var unshiftedKeySym = new Array();
unshiftedKeySym[8] = 0xFF08; // backspace
unshiftedKeySym[9] = 0xFF09; // tab
unshiftedKeySym[13] = 0xFF0D; // enter
unshiftedKeySym[16] = 0xFFE1; // shift
unshiftedKeySym[17] = 0xFFE3; // ctrl
unshiftedKeySym[18] = 0xFFE9; // alt
unshiftedKeySym[19] = 0xFF13; // pause/break
unshiftedKeySym[20] = 0xFFE5; // caps lock
unshiftedKeySym[27] = 0xFF1B; // escape
unshiftedKeySym[33] = 0xFF55; // page up
unshiftedKeySym[34] = 0xFF56; // page down
unshiftedKeySym[35] = 0xFF57; // end
unshiftedKeySym[36] = 0xFF50; // home
unshiftedKeySym[37] = 0xFF51; // left arrow
unshiftedKeySym[38] = 0xFF52; // up arrow
unshiftedKeySym[39] = 0xFF53; // right arrow
unshiftedKeySym[40] = 0xFF54; // down arrow
unshiftedKeySym[45] = 0xFF63; // insert
unshiftedKeySym[46] = 0xFFFF; // delete
unshiftedKeySym[91] = 0xFFEB; // left window key (super_l)
unshiftedKeySym[92] = 0xFF67; // right window key (menu key?)
unshiftedKeySym[93] = null; // select key
unshiftedKeySym[112] = 0xFFBE; // f1
unshiftedKeySym[113] = 0xFFBF; // f2
unshiftedKeySym[114] = 0xFFC0; // f3
unshiftedKeySym[115] = 0xFFC1; // f4
unshiftedKeySym[116] = 0xFFC2; // f5
unshiftedKeySym[117] = 0xFFC3; // f6
unshiftedKeySym[118] = 0xFFC4; // f7
unshiftedKeySym[119] = 0xFFC5; // f8
unshiftedKeySym[120] = 0xFFC6; // f9
unshiftedKeySym[121] = 0xFFC7; // f10
unshiftedKeySym[122] = 0xFFC8; // f11
unshiftedKeySym[123] = 0xFFC9; // f12
unshiftedKeySym[144] = 0xFF7F; // num lock
unshiftedKeySym[145] = 0xFF14; // scroll lock
// Shifted versions, IF DIFFERENT FROM UNSHIFTED!
// If any of these are null, the unshifted one will be used.
var shiftedKeySym = new Array();
shiftedKeySym[18] = 0xFFE7; // alt
/*****************************************/
/*** Keyboard Handler ***/
/*****************************************/
@@ -52,27 +98,27 @@ function GuacamoleKeyboard(element) {
function getKeySymFromKeyIdentifier(shifted, keyIdentifier) {
var unicodePrefixLocation = keyIdentifier.indexOf("U+");
if (unicodePrefixLocation >= 0) {
var unicodePrefixLocation = keyIdentifier.indexOf("U+");
if (unicodePrefixLocation >= 0) {
var hex = keyIdentifier.substring(unicodePrefixLocation+2);
var codepoint = parseInt(hex, 16);
var typedCharacter;
var hex = keyIdentifier.substring(unicodePrefixLocation+2);
var codepoint = parseInt(hex, 16);
var typedCharacter;
// Convert case if shifted
if (shifted == 0)
typedCharacter = String.fromCharCode(codepoint).toLowerCase();
else
typedCharacter = String.fromCharCode(codepoint).toUpperCase();
// Convert case if shifted
if (shifted == 0)
typedCharacter = String.fromCharCode(codepoint).toLowerCase();
else
typedCharacter = String.fromCharCode(codepoint).toUpperCase();
// Get codepoint
codepoint = typedCharacter.charCodeAt(0);
// Get codepoint
codepoint = typedCharacter.charCodeAt(0);
return getKeySymFromCharCode(codepoint);
return getKeySymFromCharCode(codepoint);
}
}
return null;
return null;
}
@@ -183,6 +229,8 @@ function GuacamoleKeyboard(element) {
return false;
}
return true;
};
// When key pressed