2

I have written one directive that disables my mouse right click,but my contextmenu still popups on SHIFT + F10

Here is my directive, which works on mouse right click event,but fails on SHIFT + F10

app.directive('prevent', function () {
    return {
        restrict: 'AE',
        link: function ($scope, $ele) {
            $ele.bind('contextmenu', function (e) {
                e.preventDefault();
            })
        }
    }

})

So i have two questions

1)- How to disable my contextmenu on SHIFT + F10 using directive

2) - Enable my context menu on SHIFT + C + S using directive

I also tried plain Javascript code but this also failed for keyboard events

document.oncontextmenu = document.body.oncontextmenu = function () { return false; }

Please can anyone help..

Parshuram Kalvikatte
  • 1,616
  • 4
  • 20
  • 40
  • This doesn't fully answer your question so posting as a comment. I found this answer which seems to suggest that handling the 'contextmenu' event should handle both the right click and SHIFT + F10 http://stackoverflow.com/questions/4909167/how-to-add-a-custom-right-click-menu-to-a-webpage the fiddler link seems to work the way you want. and you should be able to display of your own context menu without having a separate shortcut keys. – philreed Dec 19 '16 at 12:16
  • But Shift + F10 is still not disable with that,,mouse right click event is only disabled.. i want both to be disabled.. – Parshuram Kalvikatte Dec 19 '16 at 12:20
  • Also, HTML5 context menus coming soon to a browser near you : https://davidwalsh.name/html5-context-menu – philreed Dec 19 '16 at 12:20
  • http://stackoverflow.com/a/28575776/6138201......... – Chintan Pandya Dec 19 '16 at 12:20
  • Did you see the fiddler link ( http://jsfiddle.net/nhvv6/ ) Click into the demo area (bottom right section and press SHIFT + F10. I hit SHIFT + F10 and i got the custom alert instead of the default context menu. (using Chrome) – philreed Dec 19 '16 at 12:21
  • @philreed i checked that shift + f10 shows me context menu, which needs to be disabled.. – Parshuram Kalvikatte Dec 19 '16 at 12:22
  • Even if you click with your mouse in the bottom right area? I've created a new jsfiddle to make it clear where to click first: http://jsfiddle.net/nhvv6/1285/ – philreed Dec 19 '16 at 13:16
  • I focused on that demo area and i clicked shift + F10 it opened context menu – Parshuram Kalvikatte Dec 19 '16 at 13:20
  • How strange, it works for me in Chrome, IE and EDGE. – philreed Dec 19 '16 at 13:38
  • Sorry but its not working in Mozilla – Parshuram Kalvikatte Dec 22 '16 at 05:28

0 Answers0