简体   繁体   English

如何创建键盘快捷键以在使用 javascript 的网页上执行按钮?

[英]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').所以我想知道是否有一种方法可以为该按钮创建一个键盘快捷键,使用它的 javascript url 目标(在本例中为 javascript:void('Iniciar/Detener Dictado')。

I use Chrome as my browser.我使用 Chrome 作为我的浏览器。 Thanks in advance!提前致谢!

This is the picture of the URL: When I put my mouse over the button, the destination url is javascript:void('Iniciar/Detener Dictado')这是 URL 的图片:当我将鼠标放在按钮上时,目标 url 是 javascript:void('Iniciar/Detener Dictado')

You may install a Javascript injector on your browser.您可以在浏览器上安装 Javascript 注入器。 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.您应该寻找一种可以让您根据网站的 URL 放置代码的方法,这样您就不会向网站添加不必要的代码。

Here are Chrome JS injector plugins: https://chrome.google.com/webstore/search/javascript%20inject以下是 Chrome JS 注入器插件: https ://chrome.google.com/webstore/search/javascript%20inject

After that, you may inject this Javascript (edit the combo to suit your needs):之后,您可以注入此 Javascript(编辑组合以满足您的需要):

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM