开发者

How can I add hotkeys with Safari extension

Can I listen to hotkeys with safari extension?

I want to respond to Cmd+SomeKey with action done by extension, but I've read intro on apple developer and there is nothing about hotkeys.

You can add custom buttons to the Safari toolbar, create bars of your own, add contextual menu items, display content in bars or tabs, and inject scripts and style sheets into webpages.

No single word开发者_JAVA技巧 about hotkeys, and google doesn't find any article about that. So is it possible at all? If it is possible, where can I get additional info?


It can be done -- someone helped me to set it up for my browser window resizer extension. You need to have an injected script that checks for a specific keypress/combo then send a message back to your toolbar or global page. Here's an example on github of an inject script to monitor for specific keypresses (alt-1 to alt-0) and here's an example of doing something with the message lines 92-108 & 131 of this toolbar page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜