GUAC-862: Interpret events with reliable keyCodes.

This commit is contained in:
Michael Jumper
2014-09-22 13:19:18 -07:00
parent ed69dc23b1
commit c6e3f3c686

View File

@@ -682,9 +682,41 @@ Guacamole.Keyboard = function(element) {
*/ */
function interpret_events() { function interpret_events() {
// TODO: Implement // Peek at first event in log
console.log(eventLog); var first = eventLog[0];
if (!first)
return false;
// Keydown event
if (first instanceof KeydownEvent) {
// If key is known from keyCode, use that
var keysym = keysym_from_keycode(first.keyCode, first.location);
if (keysym) {
eventLog.shift();
return !press_key(keysym);
}
}
// Keyup event
else if (first instanceof KeyupEvent) {
// If key is known from keyCode, use that
var keysym = keysym_from_keycode(first.keyCode, first.location);
if (keysym) {
eventLog.shift();
release_key(keysym);
return true;
}
}
// Dump any other type of event (keypress by itself is invalid)
else
eventLog.shift();
// Do not prevent anything by default
return false; return false;
} }