Felipe Castillo
Felipe Castillo

Reputation: 9

How can I create a keyboard shortcut to execute a button on a webpage that uses javascript?

I daily use a webpage that has a button that I have to "manually" press everytime.

So I was wondering if there is a way to create a keyboard shortcut for that button, using its javascript url destination (in this case javascript:void('Iniciar/Detener Dictado').

I use Chrome as my browser.

This is the picture of the URL: When I put my mouse over the button, the destination url is javascript:void('Iniciar/Detener Dictado')

Upvotes: 0

Views: 1020

Answers (1)

shtef21
shtef21

Reputation: 11

You may install a Javascript injector on your browser. You should seek the one that lets you put code depending on the site's URL, so that you do not add unnecessary code to websites.

Here are Chrome JS injector plugins: https://chrome.google.com/webstore/search/javascript%20inject

After that, you may inject this Javascript (edit the combo to suit your needs):

document.addEventListener('keyup', function(event) {
    if (event.key == 'z' && event.ctrlKey) {
        // CTRL + Z trigger
    }
});

Upvotes: 1

Related Questions