访问"媒体键"从浏览器选项卡中 [英] Access to "media keys" from within a browser tab

查看:131
本文介绍了访问"媒体键"从浏览器选项卡中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有从浏览器标签/窗口中访问媒体键使用Javascript的方式?

Is there a way to access the "media keys" with Javascript from within a browser tab/window?

我主要兴趣在谷歌浏览器的解决方案。

I am mainly interested in a google chrome solution.

使用以下code,似乎没有成为媒体键生成一个事件:

Using the following code, there doesn't seem to be an event generated for the media keys:

<html>
<body onKeyDown="showKeyCode(event)">
    <script type="text/javascript">

        function showKeyCode(event) {
            alert(event.keyCode);
        }

    </script>
</body>
</html>

我缺少的东西吗?我可以用谷歌Chrome扩展??做的更好。

Am I missing something? Could I do better with a Google Chrome extension??

更新:来解决这个问题,我制作了以下工具:

Update: to address this problem I crafted the following tools:

  • Chrome MusicMan
  • Mediakeys Server

推荐答案

至于是否可​​以做比Chrome扩展更好:不,你不能 - 我做了一个脚本内容为网站,而目前中运行它在OS X 10.7的Chrome 16稳定版。该脚本很简单:

Regarding whether you could do better than a Chrome Extension: no you could not - I've made a content script for a site, and running it within the current stable release of Chrome 16 on OS X 10.7. The script is simple enough:

console.log('Content script loading');

$("body").bind("keyup",function(event){
    console.log(event.keyCode);
})

和它表明的没有事件触发后,播放/暂停,前进,静音,降低音量或音量键

有趣的未使用F5键去生成一个密钥code,所以如果你想你可能使用它作为替代。

Interesting the unused F5 key goes generate a keycode, so you could potentially use it as an alternative if you wish.

这篇关于访问&QUOT;媒体键&QUOT;从浏览器选项卡中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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