3 ms·
This sequence seems to settle right around 50%: var simulateKeyPress = function(character) { var evt = document.createEvent("KeyboardEvent"); evt.ini
by Bognar 10y ago
This sequence seems to settle right around 50%:
var simulateKeyPress = function(character) {
var evt = document.createEvent("KeyboardEvent");
evt.initKeyEvent ("keypress", true, true, window,
0, 0, 0, 0,
0, character.charCodeAt(0))
document.body.dispatchEvent(evt);
};
var num = 0;
var loop = function() {
console.log(num);
var binary = num.toString(2);
num++;
for(var i = 0, len = binary.length; i < len; i++) {
simulateKeyPress(binary[i] == '0' ? 'd' : 'f');
}
};
setInterval(loop, 100);
- thaumasiotes 10y agoIt might sound weird, but I actually found that more readable as three lines of code. :/