accesskey VS navigator键盘快捷键
这似乎是一个反复出现的棘手问题,但我仍然没有解决办法或解决方法:
有没有办法在键盘快捷键之前拦截访问键?
我需要在我的最爱导航器 IE 和 FF 上使用 accesskeys,但我不想将现有的快捷键视为保留。否则它不会留下很多可能性(目前我只使用数字)。
注意:accesskey 是指 accesskey
html 属性。
有什么想法吗? Flash 应用程序可以做到这一点,那么 JavaScript 呢?
For example here is an accessible control:
<button onclick="alert('Hello');" accesskey="F">Alt+F to activate</button>
当我尝试激活它时,我只需打开文件菜单:'(
It seems to be a recurrent tricky question but I still don't have a fix nor workaround for it:
Is there a way to intercept accesskeys before keyboard shortcuts?
I need to use accesskeys on my favorites navigator IE and also FF, but I don't wan't to consider existing shortkeys as reserved. Otherwise it doesn't leave a lot of possibilities (currently I only use numbers).
Note: by accesskey, I mean the accesskey
html attribute.
Any idea ?
Flash apps can do it, so what about JavaScript ?
For example here is an accessible control:
<button onclick="alert('Hello');" accesskey="F">Alt+F to activate</button>
When I try to activate it I just open File menu :'(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
John Resig(jQuery 的创建者)一直致力于 jQuery 的“热键”插件,它应该可以满足您的需求。
https://github.com/jeresig/jquery.hotkeys
我知道这不是 ' jQuery 问题”,并为“小”东西添加一个框架并不理想,但它应该提供一个解决方案。另一方面,你总是可以看看他是如何做到的以获得灵感。
John Resig (the creator of jQuery) has been working on a "hotkey" addon for jQuery which should do what you are looking for.
https://github.com/jeresig/jquery.hotkeys
I know this isn't a 'jQuery question', and adding a framework for something 'small' isn't ideal, but it should offer a solution. On the other hand, you can always look over how he did it for inspiration.
显然,这取决于浏览器。对于“三巨头”:
简而言之:
不,没有办法覆盖 Javascript 中的浏览器行为(可以说这将是一个安全漏洞),但所有浏览器都有办法处理这些冲突。
This will, obviously, depend on the browser. For the "big three":
In short:
No, there is no way to override the browser behavior in Javascript (and arguably that would be a security vulnerability), but all browser have ways to handle these conflicts.