问题
I need a Google Chrome extension that simply disables the built in alte shortcut and pass it to the HTML accesskey as ordinary. (yes, that all - no configuration/graphics)
It's for an in-house web-application and I don't want to use existing extensions.
I've browsed the extension documentation but would be thankful for a jump start in this matter.
回答1:
Unfortunately there's no way to hook into global hotkeys. The best you can do is add a window event keypress listener.
Source: a Chromium developer post on the chromium-extensions group.
Related Question: Keyboard Shortcuts in Google Chrome / Chromium Extensions
回答2:
For reference, (modified from http://www.catswhocode.com/blog/using-keyboard-shortcuts-in-javascript):
var isAlt = false;
$(document).keyup(function (e) {
if(e.which == 18) isAlt=false;
}).keydown(function (e) {
if(e.which == 18) isAlt=true;
if(e.which == 69 && isAlt == true) {
alert('Keyboard shortcuts + JQuery are even more cool!');
return false;
}
});
来源:https://stackoverflow.com/questions/18249790/how-to-write-a-google-chrome-extension-that-disables-a-default-keyboard-shortcut