set interval between 'keys' events to 250 ms

This commit is contained in:
rolux 2012-06-30 11:21:23 +02:00
parent 7df61a8ac9
commit dfa0a9b8eb

View file

@ -63,12 +63,12 @@ Ox.Keyboard = (function() {
// clear the trigger timeout only if the key went into the buffer // clear the trigger timeout only if the key went into the buffer
clearTimeout(triggerTimeout); clearTimeout(triggerTimeout);
triggerTimeout = setTimeout(function() { triggerTimeout = setTimeout(function() {
focused !== null && Ox.UI.elements[focused].triggerEvent('keys', { if (focused !== null) {
keys: buffer Ox.UI.elements[focused].triggerEvent('keys', {
}); keys: buffer
}, 25); });
// fixme: used to be 250, but seemed too much. }
// if it stays at 25, we may not need a timeout at all }, 250);
} }
} }
// clear the reset timeout even if the key didn't go into the buffer // clear the reset timeout even if the key didn't go into the buffer
@ -77,7 +77,7 @@ Ox.Keyboard = (function() {
buffer = ''; buffer = '';
}, 1000); }, 1000);
//Firefox will cancel active XMLHttpRequests otherwise // Firefox cancels active XMLHttpRequests when pressing escape
if (keyName == 'escape') { if (keyName == 'escape') {
event.preventDefault(); event.preventDefault();
} }