Is it possible to block the Windows Key from a web browser?

做~自己de王妃 提交于 2019-12-09 03:54:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!