Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.title = 'Stackoverflow - directivas';
- var SplitInterval;
- var MacroInterval;
- var SplitDebounce = false;
- var MacroDebounce = false;
- $(document).on('keydown', function(input) {
- console.log("got keydown")
- if (input.keyCode == 68) {
- if (SplitDebounce) {
- return;
- }
- SplitDebounce = true;
- SplitInterval = setInterval(function() {
- $("body").trigger($.Event("keydown", {
- keyCode: 32
- }));
- $("body").trigger($.Event("keyup", {
- keyCode: 32
- }));
- }, 1);
- } else if (input.keyCode == 70) {
- if (MacroDebounce) {
- return;
- }
- MacroDebounce = true;
- MacroInterval = setInterval(function() {
- $("body").trigger($.Event("keydown", {
- keyCode: 87
- }));
- $("body").trigger($.Event("keyup", {
- keyCode: 87
- }));
- }, 0);
- }
- })
- ///////////////////////////////-------------------------------/////////////////////////////
- $(document).on('keyup', function(input) {
- if (input.keyCode == 68) {
- SplitDebounce = false;
- clearInterval(SplitInterval);
- return;
- } else if (input.keyCode == 70) {
- MacroDebounce = false;
- clearInterval(MacroInterval);
- return;
- }
- })
- setTimeout(function(){
- (function() {
- var amount = 2;
- var duration = 50; //ms
- var overwriting = function(evt) {
- if (evt.keyCode === 65) { // KEY_Ga
- for (var i = 0; i < amount; ++i) {
- setTimeout(function() {
- window.onkeydown({keyCode: 32}); // KEY_SPACE
- window.onkeyup({keyCode: 32});
- }, i * duration);
- }
- }
- };
- window.addEventListener('keydown', overwriting);
- })();
- //as
- (function() {
- var amount = 3;
- var duration = 50; //ms
- var overwriting = function(evt) {
- if (evt.keyCode === 83) { // KEY_S
- for (var i = 0; i < amount; ++i) {
- setTimeout(function() {
- window.onkeydown({keyCode: 32}); // KEY_SPACE
- window.onkeyup({keyCode: 32});
- }, i * duration);
- }
- }
- };
- window.addEventListener('keydown', overwriting);
- })();
- ///////////////////
- (function() {
- var amount = 5;
- var duration = 40; //ms
- var overwriting = function(evt) {
- if (evt.keyCode === 82) { // KEY_S
- for (var i = 0; i < amount; ++i) {
- setTimeout(function() {
- window.onkeydown({keyCode: 32}); // KEY_SPACE
- window.onkeyup({keyCode: 32});
- }, i * duration);
- }
- }
- };
- window.addEventListener('keydown', overwriting);
- })();
- },3000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement