Application Remembers that Alt Key Was Pressed after Alt+Tab Away

When I use Alt+Tab to switch away from an application, then return to that application, the Alt key does not work on the first press. Here's how to reproduce

  • Open Chrome and Notepad++
  • Activate Notepad++ using any method you like
  • Alt+Tab to activate Chrome
  • Alt+Tab to activate Notepad++
  • Press the Alt key one time

The menu in Notepad++ is not activated.

This is reproducible for me using most applications. Notepad++ is the one that clued me in to what's happening, though. When I Alt+Tab away from Notepad++, I can see that the menu selectors (underlines) are visible. They remain visible even as the application is inactive and when I reactivate it. When I return to the app, the Alt key removes the menu selectors - the opposite of what I want it to do.

The only application where this doesn't happen, that I've tried so far, is SQL Server Management Studio (but I've only tried about a dozen). No matter how I activate and deactivate SSMS, the Alt key activates the menu on the first press.

It's easy to see that the menu selectors are being activated in Notepad++, but less easy in applications that use a RibbonUI, like Office. It doesn't show the Ribbon tooltips like pressing Alt alone in the application, but the effect is the same. That is, when I return to the application, I have to press Alt twice to see the tooltips.

It seems like I'm activating the menu before leaving the application, but that's not quite right. It's some weird third state. All other keys except Alt work as expected. If I activate the menu in Notepad++, then press the down arrow key, the File menu expands. But if I Alt+Tab away from Notepad++, then reactivate, the down arrow moves the cursor down one row as expected. So it's not as if Alt is necessarily persisting such that a down arrow would still expand the menu.

I want to Alt+Tab away from Excel, Alt+Tab back to Excel, press Alt+A+C, and not have AC appear in the active cell.

Screen shots: When Alt-tabbing from Notepad++, you can see the hotkeys are underlined in the menu

Alt tab away from Notepadd++

When Alt-tabbing from Excel, no tooltips are shown

Alt tab away from Excel

I can't show you how when I return to Excel and press Alt, nothing happens, because nothing happens. If you can think of a particular screen shot you'd like to see, I'll provide it.


Open registry and go to the following key:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer
note that you must be in Explorer key and not in its sub trees.
create a new 32-bit DWORD value named AltTabSettings and set it to 1.
Sign out from your Windows 10 session and sign in again.

Note
you can roll back the changes by deleting new value you created.


My take on the issue is that this is unavoidable :

Alt-down is sent to the application, then Tab-down gets handled by Windows which switches the focus away. The result is that Alt-up is never sent, so the application menu stays int Alt-pressed mode. When you now do Alt-Tab and give the application back the focus, the first Alt you press just undoes the Menu mode.

The rest is just the internal bookkeeping of the application and how it handles the sequence of Alt-down/Focus-out/Focus-in. Some applications might be intelligent enough to after a focus-out to undo the Alt-down. From your testing it seems that most applications don't handle this case.

This is the behavior that I observe on a new Windows 10 VM and also on my own computer, so this problem is the default condition for Windows 10. It seems like some people do not experience this problem, but the reason why it doesn't happen on their computers is still unknown to me at this time.