Keyboard - touch repeat
https://github.com/Mottie/Keyboard
by Mottie
HTML
<link rel="stylesheet" href="http://mottie.github.com/Keyboard/css/keyboard.css">
<script src="http://mottie.github.com/Keyboard/js/jquery.keyboard.js"></script>
<script src="http://mottie.github.com/Keyboard/js/jquery.mousewheel.js"></script>
<script src="http://mottie.github.com/Keyboard/js/jquery.keyboard.extension-typing.js"></script>
<script src="http://mottie.github.com/Keyboard/js/jquery.keyboard.extension-autocomplete.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-lightness/jquery-ui.css">
<div id="wrap">
<textarea id="keyboard" type="text"></textarea>
</div>
CSS
body { font-size: 10px; margin-top: 200px; }
#wrap { display: block; margin: 0 auto; width: 200px; }
JavaScript
// delay and rate exaggerated for demo purposes
// **********************************************
var delay = 1500, // delay in milliseconds
rate = 10, // characters per second
// repeat key function
t, repeatKey = function(key) {
// trigger
key.trigger('mousedown.keyboard');
t = setTimeout(function(){ repeatKey(key); }, time);
};
time = 1000/rate;
$('#keyboard').keyboard({
visible: function(e, kb) {
kb.startTime = kb.lastTime = 0;
kb.$allKeys.filter(':not(.ui-keyboard-actionkey)')
// include any action key exceptions here
.add('.ui-keyboard-tab, .ui-keyboard-bksp, .ui-keyboard-space, .ui-keyboard-enter')
// make sure we don't have multiple binds
.unbind('mousedown.kb mouseup.kb touchstart.kb touchend.kb')
.bind('mousedown.kb touchstart.kb', function() {
var key = $(this);
// add delay prior to repeat
t = setTimeout(function(){
repeatKey( key );
}, delay);
})
.bind('mouseup.kb touchend.kb', function() {
// clear repeat
clearTimeout(t);
});
}
});