我想知道是否可以使用Macbook Pro具有的特殊键进行音乐控制并将其绑定到javascript中?
按键示例:播放/暂停,下一步,返回。

如果有帮助,我正在尝试执行此操作以修改油脂猴子脚本。

这是当前代码

HotKeys.bindings['/'] = HotKeys.activateSearch;
HotKeys.bindings['p'] = HotKeys.playPrev;
HotKeys.bindings['n'] = HotKeys.playNext;
HotKeys.bindings['k'] = HotKeys.selectPrev;
HotKeys.bindings['j'] = HotKeys.selectNext;
HotKeys.bindings['o'] = HotKeys.playSelected;
HotKeys.bindings['v'] = HotKeys.openBlog;
HotKeys.bindings['s'] = HotKeys.toggleFavorite;

HotKeys.keyBindings[27] /*ESC*/ = HotKeys.deactivateSearch;


脚本来源:http://userscripts.org/scripts/review/23612

最佳答案

只需将按键事件侦听器应用于文档,然后将事件记录到控制台即可查看它是否注册。与此类似:http://unixpapa.com/js/testkey.html

关于javascript - 在Javascript中使用特殊键进行键提示,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2947169/

10-11 17:41