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

后端 未结 1 1155
走了就别回头了
走了就别回头了 2021-01-27 04:27

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 t

相关标签:
1条回答
  • 2021-01-27 05:08

    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.

    0 讨论(0)
提交回复
热议问题