Advertisement
Guest User

Untitled

a guest
Jun 24th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1.  
  2. function pressSpace(target, type) {
  3. var press = new KeyboardEvent(type, {"keyCode": 32});
  4. if(type == 'keyup'){ target.value += ' ';}
  5. target.dispatchEvent(press);
  6. }
  7.  
  8. function type(){
  9. var text = document.getElementById('words');
  10. var currentword = document.getElementById('currentword');
  11. var input = document.getElementById('input');
  12.  
  13. if(input.value.indexOf('currentword.innerText') == -1){
  14. input.value = currentword.innerText;
  15. pressSpace(input, 'keydown');
  16.  
  17. setTimeout( function(){
  18. pressSpace(input, 'keyup');
  19. }, 200);
  20. }
  21.  
  22. }
  23.  
  24.  
  25. // document.getElementById('input').addEventListener('keyup', function(evt){ console.log(evt.keyCode); } );
  26. var handler = setInterval(type, 200);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement