Google Chrome / Chromium扩展程序中的键盘快捷键 [英] Keyboard Shortcuts in Google Chrome / Chromium Extensions

查看:427
本文介绍了Google Chrome / Chromium扩展程序中的键盘快捷键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为Google Chrome创建了一个基本的扩展程序,以更改选择哪个选项卡时的行为您关闭选项卡,以便所选选项卡是您选择的最后一个选项卡,而不仅仅是您关闭选项卡之前的选项卡。

I've created a basic extension for Google Chrome to change the behavior of which tab is selected when you close a tab so that the selected tab is the last one you had selected instead of just the one before the tab you closed.

我想添加键盘快捷键,并且我找到了一种使用jQuery和 jquery快捷键的方法,但问题是我发现键盘快捷键只在页面加载后才起作用。因此,例如,如果您打开新的选项卡而不去任何地方,则快捷键不起作用,因为只有当屏幕上出现页面时才会加载JavaScript。如果您在某个标签中打开了扩展程序页面,则会出现同样的问题。

I want to add keyboard shortcuts, and I've found a way to do that using jquery and jquery hotkeys, but the problem I'm finding is that the keyboard shortcuts only work once a page is loaded. So for example, if you open a new tab without going anywhere, the shortcut keys don't work because the javascript only loads when a page is on the screen. Same problem if you have the extensions page open in a tab.

有谁知道在Chrome扩展程序中使用键盘快捷键的更好方法吗?我一直在浏览扩展程序文档,但我没有找到任何内容这看起来很有希望。

Does anyone know of a better way to do keyboard shortcuts in Chrome extensions? I've been looking through the extensions documentation, but I haven't found anything that looks promising.

推荐答案

不幸的是,没有办法挂钩全局热键。您可以做的最好的事情是添加一个窗口事件按键监听器。

Unfortunately there's no way to hook into global hotkeys. The best you can do is add a window event keypress listener.

来源:铬扩展组中的Chromium开发者帖子

这篇关于Google Chrome / Chromium扩展程序中的键盘快捷键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆