问题
I have a fairly sophisticated Single Page Application, with a nice little menu system (similar to Windows 8 start menu). I'd like for my users to hit the Windows key to open this menu when within my application. I have this successfully functioning, however it also brings up the Microsoft Windows start menu.
Is there a way (from a web browser) I can "block" the Microsoft Windows Start Menu from appearing when I hit the Windows Key within my web app?
I'm using latest jQuery, knockoutJS, and any necessary JavaScript plugin to accomplish this task.
回答1:
Write a custom binding handler for your button action -
ko.bindingHandlers.windowsKey = {
init: function (element, valueAccessor, allBindingsAccessor, viewModel) {
var value = ko.utils.unwrapObservable(valueAccessor());
$(element).keydown(function (e) {
if (e.which === 91 || e.which == 93) {
value(viewModel);
}
});
}
};
As per the question of whether you can disable a button in Windows from the browser, see the answer that Daniel White posted that no, this cannot be done.
来源:https://stackoverflow.com/questions/18984997/is-it-possible-to-block-the-windows-key-from-a-web-browser