Keyboard Shortcut Key VS

This seems to be a repeating tricky question, but I still don't have a fix and a workaround:

Is there a way to intercept the access keys before the shortcut keys?

I need to use accesskeys in my IE navigator favorites as well as FF, but I do not want to treat existing shortcuts as reserved. Otherwise, this does not leave many possibilities (currently I use only numbers).

Note: through accesskey, I mean the accesskey html attribute.

Any idea? Flash applications can do this, so what about JavaScript?


For example, available control is available:
 <button onclick="alert('Hello');" accesskey="F">Alt+F to activate</button> 

When I try to activate it, I simply open the File menu: "(

+8
javascript html keyboard-shortcuts access-keys
source share
2 answers

John Resig (jQuery creator) is working on a hotkey add-on for jQuery, which should do what you are looking for.

https://github.com/jeresig/jquery.hotkeys

I know this is not a jQuery question, and adding a framework for something β€œsmall” is not ideal, but it should offer a solution. On the other hand, you can always see how he did it for inspiration.

+1
source share

This will obviously be browser dependent. For the Big Three:

  • Firefox: menu shortcuts use Alt , accesskey shortcuts use Shift Alt , so there is no conflict.
  • Google Chrome: both types of shortcuts use Alt , and menu shortcuts take precedence, but if there is a conflict, the "accesskey" shortcuts use Shift Alt , so they are still available. See My answer to Disable Alt Features (Shortcuts) in Google Chrome for an example.
  • Internet Explorer: both types of shortcuts use Alt , and accesskey shortcuts take precedence - just what you want :-).

In short: No, you cannot override browser behavior in Javascript (and perhaps it will be a security vulnerability), but all browsers have ways to deal with these conflicts.

0
source share

All Articles