Skip to content

[Feature Request]: Disable alt-key menu bar focus globally as user #34211

Description

@haoadoreorange

Preflight Checklist

Problem Description

Hi,

I'm on Linux desktop and assign various shortcuts with alt key. Electron uses the alt key to focus on the menu bar and I don't use the menu bar that much (if at all) to find it useful, this inteferes with Electron apps whenever I use the shortcut (mainly toggle the menu bar). Aside from shorcuts, on GNOME there's the alt+click to drag windows which also trigger the menu bar every time.

The alt key is a very convenient one and I would prefer it much for my shortcuts over the menu bar which I rarely use. I know there's already a fix #12167 but I still have that problem sometimes, for example I use a shortcut <alt+F3> in vscode that focus the menu bar everytime, I ended up using the custom menu bar to disable that behaviour, but other Electron apps don't have that.

Would it be possible to allow users to disable the key globally, similar to GTK with gtk-auto-mnemonics=0 ?

Proposed Solution

Allow users of Electron apps to disable alt key focus menu bar behaviour

Alternatives Considered

Not sure

Additional Information

No response

Activity

  1. scorchedegg commented on Jul 12, 2022

    @scorchedegg

    I tend to press Alt a lot, sometimes for no reason. Since Electron started focusing the menu bar when Alt is pressed, it's made using Electron apps a nightmare for me because editors and textboxes get defocused.

    PLEASE give us some way to disable this functionality. Literally no other desktop apps do this, so I don't understand why it's even a thing.

  2. wlwl2 commented on Jul 12, 2022

    @wlwl2

    @slightlyfaulty You can just have a system where it is enabled/disabled (can be toggled). I am not sure what the original intention of the new alt functionality was. This has been an issue for a long time now. It could maybe be the case that there was a change in the operating systems but if I remember correctly (this may not be the case) this issue occurs in Ubuntu as well as Windows.

  3. scorchedegg commented on Jul 12, 2022

    @scorchedegg

    Well I just found out it can be disabled in VS Code with the window.customMenuBarAltFocus and window.enableMenuBarMnemonics settings. I also had to change window.menuBarVisibility for these settings to work on Linux. At least this covers one of the Electron apps I use.

  4. flikier commented on Nov 1, 2022

    @flikier

    I'm joining the request 🙏 I'm used to use alt+space for changing leyboard layout and half of the times the language doesn't change and instead I lose the focus to the menu bar...

  5. matheus-santana1 commented on Jan 9, 2023

    @matheus-santana1

    image
    tente isso...
    win.removeMenu()

  6. ygoe commented on Feb 5, 2023

    @ygoe

    Same problem here. I use Alt+Backspace to undo (as is common in Windows) and Alt+ArrowUp/Down to move lines in VSCode. It seems like when I press the Alt key long enough, it doesn't trigger the menu bar. But when I'm working quicker and only hold the Alt key for a short period of time, I always end up losing the text focus and the menu bar jumps in and interrupts me. Very annoying! I really hope there can be a fix for this.

    After all, it should be very simple. Press the Alt key and release it, then focus the menu bar, as every other Windows application does. But press the Alt key and then press any other key before releasing Alt, then it's not for you, dear menu bar! That part is missing and the menu bar still thinks I wanted to talk to it, but missed that I was typing something else in between.

    From this perspective, I don't consider this an enhancement but rather a bug.

  7. teras commented on Feb 19, 2023

    @teras

    For i18n reasons, as a person who is using a dual-layout for the greek language (as eveyone who is using the greek language), the keyboard shortcut to change the layout is (almost always) [ALT]-[SHIFT].

    If I press ALT, then SHIFT, then release SHIFT, then ALT, everything is OK. If (since most of the times I am too fast typing), I first release ALT and then SHIFT, then the focus goes on the menu bar, and everything I am writing afterwards is lost :(

    And btw this is a problem that a lot of my fellow greek users are also having 😭

    There's a similar (closed) issue with the same problem here: #28088

  8. thanosk commented on Feb 20, 2023

    @thanosk

    Another Greek here joining the request 🙏

    I'm having this problem when using Electron Mattermost client on Linux Desktop (no matter the distro/desktop environment combination).

  9. msergein commented on Feb 23, 2023

    @msergein

    this is a problem with all my used electron apps: vscode and logseq.
    My native language doesn't use latin characters and I often switch keyboard layouts with alt+shift and losing focus makes typing a nightmare

    OS: Linux, Fedora Linux 37 (Workstation Edition)

  10. ygoe commented on Feb 23, 2023

    @ygoe

    If I press ALT, then SHIFT, then release SHIFT, then ALT, everything is OK. If (since most of the times I am too fast typing), I first release ALT and then SHIFT, then the focus goes on the menu bar, and everything I am writing afterwards is lost :(

    That's an interesting observation. I can confirm that behaviour. And it probably explains why I see it sometimes, and sometimes not, but always for quick typing where I might release the two keys in a random order. Maybe I can try to watch out for this and train myself to avoid the issue by typing "more carefully" (hold the Alt key for longer). ;-)

    And hopefully, this observation helps resolve the bug eventually. If anybody is interested in solving it. I haven't seen a project developer in this issue yet, or at least didn't recognise one by their comment. I'm not sure if this project is maintained at all! Unfortunately, VSCode relies on it.

  11. msergein commented on Feb 24, 2023

    @msergein

    for vs code found a workaround

    set settings

    "window.titleBarStyle": "custom"
    "window.customMenuBarAltFocus": false
    "window.enableMenuBarMnemonics": false
    "window.menuBarVisibility": "visible"

    after change settings, perhaps need to reload the window: Ctrl+Shift+P and select Developer: Reload window

    but there is no solution for logseq

  12. ygoe commented on Feb 24, 2023

    @ygoe

    I don't consider the custom titlebar a workaround or even a solution. It's a whole new problem. For example, it won't indicate whether the window is active and receives keyboard input or not. Native title bars do that (if you activate the option in the Windows settings, just like it has always been until Windows 7, before Microsoft decided that keyboards are useless).

  13. WebDevManuel commented on Apr 9, 2023

    @WebDevManuel

    for vs code found a workaround

    set settings

    "window.titleBarStyle": "custom"
    "window.customMenuBarAltFocus": false
    "window.enableMenuBarMnemonics": false
    "window.menuBarVisibility": "visible"

    after change settings, perhaps need to reload the window: Ctrl+Shift+P and select Developer: Reload window

    but there is no solution for logseq

    thank you, this has helped me a lot and works well.

  14. msergein commented on May 13, 2023

    @msergein

    this issue is a year old, do you plan to do something? thanks

  15. 5 remaining items

  16. ygoe commented on Oct 6, 2023

    @ygoe

    @swork9 What is xmodmap? Is that available on Windows?

  17. scorchedegg commented on Oct 6, 2023

    @scorchedegg

    @ygoe No xmodmap is Linux only. However this isn't a very good workaround since it's basically rebinding your Alt key to Right-Ctrl for your entire system. It also only works for older Linux systems running X11 and not Wayland.

  18. swork9 commented on Oct 6, 2023

    @swork9

    Exactly, as mentioned above, this solution is only for Linux & legacy X11. It's definitely not perfect, but it's working and allowing me to work with Electron apps. Unfortunately, I can't find better workaround for this problem.

  19. n-r-w commented on May 20, 2024

    @n-r-w

    Still no solution found? It gets annoying, for example, when working in RocketChat using wayland

  20. azizsayfiddin commented on Aug 8, 2024

    @azizsayfiddin

    Same issue.

  21. mifi commented on Oct 5, 2024

    @mifi
    Contributor

    If you're developing an app and want to disable the alt menu shortcut, I've found this works:

    addEventListener("keydown", (e)=>
    {
        if (e.altKey)
            e.preventDefault();
    });
    

    Looks like this is what vscode is doing too:

    https://github.com/microsoft/vscode/blob/51cfc9ece448a8aa328b22f33b012417ebf10a69/src/vs/base/browser/ui/menu/menubar.ts#L931

    		// Prevent alt-key default if the menu is not hidden and we use alt to focus
    		if (modifierKeyStatus.event && this.shouldAltKeyFocus) {
    			if (ScanCodeUtils.toEnum(modifierKeyStatus.event.code) === ScanCode.AltLeft) {
    				modifierKeyStatus.event.preventDefault();
    			}
    		}
    
    		// Alt key pressed while menu is focused. This should return focus away from the menubar
    		if (this.isFocused && modifierKeyStatus.lastKeyPressed === 'alt' && modifierKeyStatus.altKey) {
    			this.setUnfocusedState();
    			this.mnemonicsInUse = false;
    			this.awaitingAltRelease = true;
    		}

    https://github.com/microsoft/vscode/blob/51cfc9ece448a8aa328b22f33b012417ebf10a69/src/vs/base/browser/dom.ts#L1993

    		disposables.add(addDisposableListener(window, 'keydown', e => {
  22. altq33 commented on Feb 11, 2025

    @altq33

    image tente isso... win.removeMenu()

    this work for me, ,but it disables update ctrl+r and devtools

  23. pythoninthegrass commented on Apr 9, 2025

    @pythoninthegrass

    @msergein's workaround got vscode on linux (gnome shell) working as expected.

    Only slight correction in settings.json is the missing commas:

    "window.titleBarStyle": "custom",
    "window.customMenuBarAltFocus": false,
    "window.enableMenuBarMnemonics": false,
    "window.menuBarVisibility": "visible",
  24. artemgur commented on Oct 27, 2025

    @artemgur

    Alt menu focus regularly interferes with Alt+Shift keyboard layout switching and with custom keyboard shortcuts. And I never use Alt menu shortcuts, so this feature is completely useless for me. It annoys me for a long time, and in most apps you can't disable it. I tried many workarounds including AutoHotkey, but they usually lead to other issues
    Since this issue has been completely ignored for 3.5 years, I don't hope much that it ever gets fixed

  25. vplytus commented on Nov 29, 2025

    @vplytus

    I agree with the points raised above. The inability to disable this behaviour significantly impacts my daily workflow. Surprisingly, a problem affecting so many users who rely on multiple keyboard layouts and are accustomed to switching with Alt + Shift is still overlooked. And that’s without even mentioning the other hotkeys that are affected.

  26. ygoe commented on Nov 29, 2025

    @ygoe

    Interestingly, this should already work, but it doesn't. I don't understand the code enough to explain why.

    My background is, I'm coming from this issue in VSCode. It's about the menu being focused when pressing any key combination with the Alt modifier and releasing the Alt key sooner than after a second or so. That issue was closed and I was referred to here as they could do nothing about it.

    So I'm here and asked Copilot where the code is. (Crazy modern times.) The answer was this file, specifically the RootView::HandleKeyEvent method. In these lines, I see that

    • pressing the Alt key is remembered
    • releasing the Alt key (if pressed before) focuses the menu bar
    • but here's the interesting part: pressing any other key in between clears the pressed flag (highlighted line from the link above).

    So Pressing Alt+Up or Alt+Left at any speed should never focus the menu bar. But it clearly does, at least in the VSCode application.

    What's wrong? Is that code not working as intended? Is it too new and not included in VSCode yet? Has VSCode modified that part of the code and shipped something else than this original? (Then it would be their issue indeed.)

    Please advise.

  27. mpeshev commented on Dec 11, 2025

    @mpeshev

    As a multilingual user, confirming this bug here. I swap between languages on Slack several times PER PARAGRAPH so the time waste is massive due to the lingo across languages.

    It either needs a command line argument to launch Slack's Electron without this or a setting to invoke the menu with Alt + a specific letter to kick in (or another creative solution)

  28. tosiara commented on Sep 24, 2026

    @tosiara

    I also use Alt+Shift to switch keyboard layout, and as soon as I switch it, the focus immediately moves to menu. I went gray while trying to fix my Ubuntu, until I realized this is Electron. For the sake of humanity, fix it 😭

  29. kirmak81-spec commented on Nov 4, 2026

    @kirmak81-spec

    I’d also appreciate a user-configurable way to disable menu focus on Alt.

    On Ubuntu 26.04.1 with GNOME and Wayland, I use Alt+Shift to switch keyboard layouts. In ChatGPT/Codex and Element Desktop, the application menu sometimes takes focus after I switch. Occasionally, I can type several characters before the menu suddenly opens.

    I don’t use the menu keyboard shortcuts, so an option to disable Alt menu activation would be a useful workaround while keeping Alt+Shift for layout switching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions