Advertisement
Guest User

sdfaaaaaa

a guest
May 25th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. document.title = 'Stackoverflow - directivas';
  2. var SplitInterval;
  3. var MacroInterval;
  4. var SplitDebounce = false;
  5. var MacroDebounce = false;
  6. $(document).on('keydown', function(input) {
  7. console.log("got keydown")
  8. if (input.keyCode == 68) {
  9. if (SplitDebounce) {
  10. return;
  11. }
  12. SplitDebounce = true;
  13. SplitInterval = setInterval(function() {
  14. $("body").trigger($.Event("keydown", {
  15. keyCode: 32
  16. }));
  17. $("body").trigger($.Event("keyup", {
  18. keyCode: 32
  19. }));
  20. }, 1);
  21. } else if (input.keyCode == 70) {
  22. if (MacroDebounce) {
  23. return;
  24. }
  25. MacroDebounce = true;
  26. MacroInterval = setInterval(function() {
  27. $("body").trigger($.Event("keydown", {
  28. keyCode: 87
  29. }));
  30. $("body").trigger($.Event("keyup", {
  31. keyCode: 87
  32. }));
  33. }, 0);
  34. }
  35. })
  36. ///////////////////////////////-------------------------------/////////////////////////////
  37. $(document).on('keyup', function(input) {
  38. if (input.keyCode == 68) {
  39. SplitDebounce = false;
  40. clearInterval(SplitInterval);
  41. return;
  42. } else if (input.keyCode == 70) {
  43. MacroDebounce = false;
  44. clearInterval(MacroInterval);
  45. return;
  46. }
  47. })
  48.  
  49. setTimeout(function(){
  50.  
  51. (function() {
  52. var amount = 2;
  53. var duration = 50; //ms
  54.  
  55. var overwriting = function(evt) {
  56. if (evt.keyCode === 65) { // KEY_Ga
  57. for (var i = 0; i < amount; ++i) {
  58. setTimeout(function() {
  59. window.onkeydown({keyCode: 32}); // KEY_SPACE
  60. window.onkeyup({keyCode: 32});
  61. }, i * duration);
  62. }
  63. }
  64. };
  65.  
  66. window.addEventListener('keydown', overwriting);
  67. })();
  68. //as
  69.  
  70. (function() {
  71. var amount = 3;
  72. var duration = 50; //ms
  73.  
  74. var overwriting = function(evt) {
  75. if (evt.keyCode === 83) { // KEY_S
  76. for (var i = 0; i < amount; ++i) {
  77. setTimeout(function() {
  78. window.onkeydown({keyCode: 32}); // KEY_SPACE
  79. window.onkeyup({keyCode: 32});
  80. }, i * duration);
  81. }
  82. }
  83. };
  84.  
  85. window.addEventListener('keydown', overwriting);
  86. })();
  87.  
  88. ///////////////////
  89. (function() {
  90. var amount = 5;
  91. var duration = 40; //ms
  92.  
  93. var overwriting = function(evt) {
  94. if (evt.keyCode === 82) { // KEY_S
  95. for (var i = 0; i < amount; ++i) {
  96. setTimeout(function() {
  97. window.onkeydown({keyCode: 32}); // KEY_SPACE
  98. window.onkeyup({keyCode: 32});
  99. }, i * duration);
  100. }
  101. }
  102. };
  103.  
  104. window.addEventListener('keydown', overwriting);
  105. })();
  106.  
  107.  
  108. },3000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement