Suppressing alt showing menu?


#1

Hi! Newbie question here, how can one suppress Alt resulting in the app’s menu bar to be shown? (We’ve set ‘auto-hide-menu-bar’: true in the BrowserWindow options.) Would one do this manually on page level by document.onkeydown catching alt or is there another way?

Thanks!


#2

Is this regarding Electron? If so, it should be in the electron category.


#3

Thanks, I edited & updated the category (the Discuss link is a navigation entry at the top of Electron http://electron.atom.io – it seems the category doesn’t carry over when registering for the first time, though it does when already logged in).


#4

I don’t have an electron installation I can test on right now, but I think something along the lines of the following snippet should do the trick:

document.addEventListener('keyup', event => {
  var {keyCode, ctrlKey, shiftKey} = event
  // the Alt key has keyCode 18
  if(keyCode != 18 || ctrlKey || shiftKey) return
  event.preventDefault() // AND/OR
  event.stopImmediatePropagation()
})