Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138192

Trying to press enter key in canvas every 1 seconds using a userscript

$
0
0

I am trying to create an userscript (to use with tampermonkey) which simulates pressing the Enter button every 1 seconds.

I have tried

// ==UserScript==
// @name         Userscript
// @namespace    http://tampermonkey.net/
// @require        https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js
// @version      0.1
// @description  desc
// @author       author
// @match        https://example.com/*
// @grant        none
// ==/UserScript==


setInterval(() => 
    document.body.dispatchEvent(new KeyboardEvent("keypress", {keyCode : 13}))
, 250);

However, the keypress does not seems to works...

The body of the page contains a canvas with the id gCanvas and multiples iframes used for ads (which are, I guess, irrelevant since I use an adblocker).

Let me know if I should add a screen of the DOM of the page from the developping tools.


Viewing all articles
Browse latest Browse all 138192

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>