Skip to content

Instantly share code, notes, and snippets.

@fyhao
Created August 14, 2021 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fyhao/d99b1d36d4731ed2f2d2c47333ede8dd to your computer and use it in GitHub Desktop.
Save fyhao/d99b1d36d4731ed2f2d2c47333ede8dd to your computer and use it in GitHub Desktop.
popcat click
function send() {
var keyboardEvent = document.createEvent('KeyboardEvent');
var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? 'initKeyboardEvent' : 'initKeyEvent';
keyboardEvent[initMethod](
'keydown', // event type: keydown, keyup, keypress
true, // bubbles
true, // cancelable
window, // view: should be window
false, // ctrlKey
false, // altKey
false, // shiftKey
false, // metaKey
40, // keyCode: unsigned long - the virtual key code, else 0
0, // charCode: unsigned long - the Unicode character associated with the depressed key, else 0
);
document.dispatchEvent(keyboardEvent);
}
setInterval(send, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment